1 Reply Latest reply on Jul 31, 2010 4:30 PM by alex377

    unload multiple youtube video player

    nvdya

      hey guys...i have a problem when i was trying stop a multiple youtube streaming video in flex. i'm using 3 file in this project:videoTutorial.mxml(as main application), windowVideoTutorial.mxml (as titleWindow component), and videoTutorialx.xml (as external xml file).this is the code:

       

      videoTutorial.mxml

      <?xml version="1.0" encoding="utf-8"?>

       

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"

       

          initialize="videoService.send();" width="100%" height="100%" >

       

          <mx:HTTPService id="videoService" url="xml/VideoTutorialx.xml" result="videoHandler(event);" />

       

          <mx:Script>

       

              <![CDATA[

       

                  import mx.rpc.events.ResultEvent;

       

                  import mx.collections.ArrayCollection;

       

                  import mx.managers.PopUpManager;

       

                  [Bindable]

       

                  public var repvid:ArrayCollection;

       

                  private function videoHandler(event:ResultEvent):void{

       

                      repvid=event.result.VideoTutorial.myvideo;

       

                  }

       

                  private function launchPopUp(e:MouseEvent):void {

       

                      if(thumbClick.selectedItem){

       

                          var win :windowVideoTutorial = new windowVideoTutorial();

       

                          win.sourceVideo = thumbClick.selectedItem.urlVid;

       

                          PopUpManager.addPopUp(win,this,true);

       

                          PopUpManager.centerPopUp(win);

       

                      }

       

                  }

       

              ]]>

       

          </mx:Script>

       

          <mx:ApplicationControlBar width="100%" height="100%" horizontalAlign="center">

       

              <mx:VBox>

       

                  <mx:ApplicationControlBar width="100%" verticalAlign="middle">

       

                      <mx:Label text="Tutorial Multimedia Player"

       

                          width="100%" textAlign="center" />

       

                  </mx:ApplicationControlBar>

       

                  <mx:TileList id="thumbClick" dataProvider="{repvid}"

       

                      width="700" height="525" rowHeight="200" columnWidth="325"

       

                      click="launchPopUp(event)" verticalAlign="middle"

       

                      horizontalCenter="0" verticalCenter="0" >

       

                      <mx:itemRenderer>

       

                          <mx:Component>

       

                          <mx:VBox horizontalAlign="left" verticalAlign="top" width="100%">

       

                              <mx:Label text="{data.titleVid}" fontWeight="bold" fontSize="12"/>

       

                              <mx:Image source="{data.imageVideo}" width="150" height="150"/>

       

                          </mx:VBox>

       

                          </mx:Component>

       

                      </mx:itemRenderer>

       

                  </mx:TileList>       

                </mx:VBox>

          </mx:ApplicationControlBar>

      </mx:Application>


      windowVideoTutorial.mxml

      <?xml version="1.0" encoding="utf-8"?>

      <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"

       

          width="100%" height="100%"

       

          showCloseButton="true"

       

          close="closeWindow(event);"

       

          creationComplete="Init();">

       

          <mx:Script>

       

              <![CDATA[

       

                  import mx.events.CloseEvent;

       

                  import mx.managers.PopUpManager;   

       

                  [Bindable]

       

                  public var sourceVideo:String;       

       

                  private function closeWindow(e:CloseEvent):void {

       

                      PopUpManager.removePopUp(this);

                      {what should i write in here . . .} 

       

                  }

       

                  private function Init():void{

       

                      var url:String = sourceVideo; 

       

                      Security.allowDomain(url);                                          

       

                      youtubevid.load(url);                                                

       

                  } 

       

              ]]>

       

          </mx:Script>

       

          <mx:SWFLoader

       

              id="youtubevid" verticalAlign="top"

       

              horizontalAlign="center" 

       

              width="100%" height="100%"

       

              />

       

      </mx:TitleWindow>

       

      videoTutorialx.xml

      <?xml version="1.0" standalone="yes"?>
      <VideoTutorial>
        <myvideo>
          <titleVid>Tutorial After Effect</titleVid>
          <imageVideo>assets/videoThumbnail01.jpg</imageVideo>
          <urlVid>http://www.youtube.com/v/Gq5jTY76slU</urlVid>
        </myvideo>
        <myvideo>
          <titleVid>Tutorial Wayang</titleVid>
          <imageVideo>assets/videoThumbnail02.jpg</imageVideo>
          <urlVid>http://www.youtube.com/v/7PrXlEJb-0Y</urlVid>
        </myvideo>
        <myvideo>
          <titleVid>Tutorial premierre</titleVid>
          <imageVideo>assets/videoThumbnail03.jpg</imageVideo>
          <urlVid>http://www.youtube.com/v/XsdJA3AweXE</urlVid>
        </myvideo>
        <myvideo>
          <titleVid>Tutorial sound audio</titleVid>
          <imageVideo>assets/videoThumbnail04.jpg</imageVideo>
          <urlVid>http://www.youtube.com/v/vCWSUVi-bII</urlVid>
        </myvideo>
        <myvideo>
          <titleVid>Tutorial masking</titleVid>
          <imageVideo>assets/videoThumbnail05.jpg</imageVideo>
          <urlVid>http://www.youtube.com/v/wyXxIMWjdA4</urlVid>
        </myvideo>
        <myvideo>
          <titleVid>Video Show off</titleVid>
          <imageVideo>assets/VideoTutorial/videoThumbnail06.jpg</imageVideo>
          <urlVid>http://www.youtube.com/v/1nFXms0pqF8</urlVid>
        </myvideo>
      </VideoTutorial>

       

      i attach source code here...im waiting for your reply...thank you very much