0

I've created a video player into which I dynamically load video from another component:

 <?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()"  >   
<mx:Script>
    <![CDATA[
[Bindable] public var videoAddress:String 
private static const YOUTUBE_EMBED_URL:String =  "http://www.youtube.com/v/";           
[Bindable] public var videoUrl:String;                                  
private function init():void {
    videoUrl = YOUTUBE_EMBED_URL+videoAddress;
}           

    ]]>
</mx:Script>    
<mx:SWFLoader id="swfLoader" source="{videoUrl}"  width="800" height="600"  />
</mx:Canvas>

Here's how I load the video:

 <?xml version="1.0" encoding="utf-8"?>
 <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600">
<mx:Script>
    <![CDATA[
        private var videoPlayer:VideoPlayer;
        protected function button1_clickHandler(event:MouseEvent):void{         
            if(this.videoPlayer != null){
                this.videoPlayer.removeAllChildren();
            }
            videoPlayer = new VideoPlayer();
            videoPlayer.videoAddress = "_OBlgSz8sSM";                  
            this.addChild(videoPlayer);             
        }           
        protected function button2_clickHandler(event:MouseEvent):void{         
            if(this.videoPlayer != null){
                this.videoPlayer.removeAllChildren();
            }
            videoPlayer = new VideoPlayer();
            videoPlayer.videoAddress = "tvmIEP_BP9Q";                  
            this.addChild(videoPlayer);             
        }
    ]]>
</mx:Script>
<mx:HBox  top="600">
    <mx:Button  label="Button 1" click="button1_clickHandler(event)" />     
    <mx:Button  label="Button 2" click="button2_clickHandler(event)" />     
</mx:HBox>
 </mx:Application>

The problem I'm experiencing is that when I load another video, the old video is removed and the new video loads, but the old audio keeps playing.

How can I remove the audio?

ketan
  • 19,129
  • 42
  • 60
  • 98
SimonRH
  • 1,409
  • 2
  • 13
  • 23

1 Answers1

0

I read a post that discussed garbage collection

The solution for me was to add the following to the init() function: SoundMixer.stopAll();

Community
  • 1
  • 1
SimonRH
  • 1,409
  • 2
  • 13
  • 23