Skip navigation
Currently Being Moderated

Embedded YouTube video's keep playing audio after leaving page

Apr 25, 2012 6:54 AM

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(""));


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);



More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points