2 Replies Latest reply on Oct 29, 2012 11:34 AM by DaeY83

    StageWebView Multiple Videos

    DaeY83 Level 1

      Hi everyone,

       

      I was wondering if there is a way to play multiple videos with stage web view.  Actually i am using this code to call a youtube video:

       

      FLASH CS6 AS3:

       

      import flash.display.StageAlign;

      import flash.display.StageScaleMode;

      import flash.events.Event;

      import flash.geom.Rectangle;

      import flash.media.StageWebView;

      import flash.system.Capabilities;

       

       

      stage.align = StageAlign.TOP_LEFT;

      stage.scaleMode = StageScaleMode.NO_SCALE;

       

      var w : int = 800;

      var h : int = 600;

       

       

      var stageWebView:StageWebView = new StageWebView();

      stageWebView.stage = this.stage;

      stageWebView.viewPort = new Rectangle(0, 0, w,h);

      stageWebView.loadString( getHTML5Player("videoId") );

                          function getHTML5Player( videoId : String ) : String

                          {

                                    return "<iframe id=\"player\" type=\"text/html\" width=\"640\" height=\"390\"" +

                                              "src=\"http://www.youtube.com/embed/"+videoId+"?rel=0\ ?hd=1\ ?fs=1\" frameborder=\"0\"> </iframe>"

                          }

       

       

      This isnt my code, but i adapted from this discussion http://forums.adobe.com/message/4589135

      This code works perfectly for one video.

       

      I tried to insert it into a movieclip but didnt work it. Maybe a did it wrong.

       

      I also duplicate the code with differents video id but it only catches 1 id.

       

      If any one could help i would be grateful !!

       

      P.D: This actually works for IOS, i tested on an IPAD 2 if anyone wonders it.

       

      Greatings!

        • 1. Re: StageWebView Multiple Videos
          DaeY83 Level 1

          Ok, i am working on a posible solution that is to remove stagewebview and add a new video.

           

          So i am removing 1st stage web view:

           

          stageWebView.loadString(getHTML5Player("<!DOCTYPE HTML><html><body></body></html>"));

          stageWebView.stage = null;

          trace("cerrado2");

           

          And it is the only way so far to work fine for me. !

           

          But here comes the catch, when i try to load a new video it displays the first video!!, so i think that i am dooing it wrong.

           

          The code is the same, i try tu put something like:

           

          stageWebView2.loadString( getHTML5Player2("videoId") );

                              function getHTML5Player2( videoId : String ) : String

                              {

                                        return "<iframe id=\"player\" type=\"text/html\" width=\"640\" height=\"390\"" +

                                                  "src=\"http://www.youtube.com/embed/"+videoId+"?rel=0\ ?hd=1\ ?fs=1\" frameborder=\"0\"> </iframe>"

                              }

           

          But stills display the first video ID

           

          Any ideas???

          • 2. Re: StageWebView Multiple Videos
            DaeY83 Level 1

            FIX IT!!!

             

            var testview:StageWebView = new StageWebView();

            testview.stage = this.stage;

            testview.viewPort = new Rectangle(0, 0, w,h);

            testview.loadString( getHTML5Player("videoId") );

                                function getHTML5Player( videoId : String ) : String

                                {

                                          return "<iframe id=\"player\" type=\"text/html\" width=\"640\" height=\"390\"" +

                                                    "src=\"http://www.youtube.com/embed/"+videoId+"?rel=0\ ?hd=1\ ?fs=1\" frameborder=\"0\"> </iframe>"

                                }

             

            So obvius .! xD