1 Reply Latest reply on Dec 7, 2012 9:53 AM by heathrowe

    Switching tabs in a browser


      Greetings internet community.


      I've created an Edge animation that syncs up with an audio voiceover file. It uses the HTML5 audio tag with a simple javascript command from Edge to play the audio. It works great. But if I run it in Google's Chrome browser with mutliple tabs running, and I switch tabs in the middle of an animation, I run into a problem. The timeline appears to pause but the audio keeps going. Then when I switch back, the animation continues, but it is now out of sync with the audio.


      So, is there a way to capture the tab-switching event and pause the audio, then of course restart it when the page regains the focus?


      An alternative would be to have some sort of listener to constantly check that the audio is in sync, but I imagine that would get quite messy. I figure, worst case is that I need to include a "restart animation" button for the user to hit if it does go out of sync.


      Any suggestions?




        • 1. Re: Switching tabs in a browser
          heathrowe Most Valuable Participant

          While not tested for a sound or animation, the following worked when implemented on the Stage > focus (jquery) event handler



          $(window).focus(function() {

              // Capture message to element called Result

              sym.$("Result").html("This window has focus");

              // Add Play sound and timeline routine here

          }).blur(function() {

              // Capture message to element called Result

              sym.$("Result").html("Focus is in another window");

             //  Add Pause sound and timeline routine here