0 Replies Latest reply: Apr 25, 2012 6:54 AM by LaurensNL RSS

    Embedded YouTube video's keep playing audio after leaving page


      Hi guys,


      My problem is that when I leave the page of my website playing a YouTube video, it just keeps on playing the audio. I will put a copy of my code in this message, maybe I just need to tweek it a little.

      Somebody please help, this is very important for my website, thanks.


      So here is the code I use:




      var player:Object;


      var loader:Loader = new Loader();

      loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);

      loader.load(new URLRequest("http://www.youtube.com/v/h814ob7nCxo?version=3"));


      function onLoaderInit(event:Event):void {


          loader.content.addEventListener("onReady", onPlayerReady);

          loader.content.addEventListener("onError", onPlayerError);

          loader.content.addEventListener("onStateChange", onPlayerStateChange);





      function onPlayerReady(event:Event):void {


          trace("player ready:", Object(event).data);


          player = loader.content;


          player.setSize(480, 360);



      function onPlayerError(event:Event):void {


          trace("player error:", Object(event).data);



      function onPlayerStateChange(event:Event):void {


          trace("player state:", Object(event).data);



      function onVideoPlaybackQualityChange(event:Event):void {


          trace("video quality:", Object(event).data);