5 Replies Latest reply on Jul 12, 2014 8:45 AM by Freelance77

    Seek() Flv in next scene

    Freelance77

      Hello,

       

      I have two different scenes that I am navigating between in my project. From a button in 'scene 1', I would like to seek to a certain time in an external FLV in 'scene 2'. Here is what I have, which doesn't work. I am pretty sure the 'seek' information is not being carried between the two scenes when the button is pushed....and the video (tourvideo2) in "scene 2" autoplays from the beginning. You should be able to see what I am TRYING to do here.

       

      Any help would be appreciated!

       

      button_46.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_43);

       

      function fl_ClickToGoToAndPlayFromFrame_43(event:MouseEvent):void

      {

      var curr:Number= tourvid.playheadTime;

        tourvid.pause();

        MovieClip(this.root).gotoAndPlay(1, "Scene 2");

        Object(root).tourvid2.seek(curr);

        Object(root).tourvid2.play();

      };

       

      PS: As you see, I am trying to read the playheadTime from a video (tourvid) in "scene 1", and go to the same time in (tourvid2) contained in "scene 2".

       

      Thank you.

      Robert

        • 1. Re: Seek() Flv in next scene
          kglad Adobe Community Professional & MVP

          if you're using a streaming server (fms, red5) you cannot seek to a point in the video until it's been loaded. 

          • 2. Re: Seek() Flv in next scene
            Freelance77 Level 1

            Thanks for the reply. It is actually for an AIR iOS app, where the video will be stored locally. I am using the FLV Component.

            • 3. Re: Seek() Flv in next scene
              Freelance77 Level 1

              I thought about writing the time to an XML, and then reading it when the video in 'scene 2'  loaded, but that seems like a lot of "parts", and I was wondering if there was a way to do it within flash/as3.

              • 4. Re: Seek() Flv in next scene
                kglad Adobe Community Professional & MVP

                with an air app using an flvplayback component you can use the load method and ready event to detect when you can apply your seek method.

                • 5. Re: Seek() Flv in next scene
                  Freelance77 Level 1

                  Thanks again. I just finished using the xml method, and it seems to work fine.

                  Here is my code for anyone interested. This is a good method for many situations where you want to save data to the phone to use later (ie. game scores, etc..).

                   

                  [FROM "SCENE 1"]

                   

                  import flash.display.*;

                  import flash.events.*;

                  import flash.filesystem.*;

                  import flash.utils.*;

                   

                  button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_43);

                   

                  function fl_ClickToGoToAndPlayFromFrame_43(event:MouseEvent):void

                  {

                    var curr:Number= (Object(root).tourvid.playheadTime -3);

                   

                    var xml:XML = <dragAndDrop>

                                <timeleap>{curr}</timeleap>

                                </dragAndDrop>;

                   

                    var file:File = File.applicationStorageDirectory.resolvePath("videojump.xml");

                              var fileStream:FileStream = new FileStream();

                              fileStream.open(file, FileMode.WRITE);

                              fileStream.writeMultiByte(String(xml), "iso-8859-01");

                              fileStream.close();

                    

                    MovieClip(this.root).gotoAndPlay(1, "Scene 2");

                  };

                   

                  [THEN WITHIN "SCENE 2"]

                   

                  import flash.display.*;

                  import flash.events.*;

                  import flash.filesystem.*;

                  import flash.utils.*;

                   

                    var file:File = File.applicationStorageDirectory.resolvePath("videojump.xml");

                    if (file.exists){

                    var document:XML;

                      var stream:FileStream = new FileStream()

                      stream.open(file, FileMode.READ);

                      document = XML(stream.readUTFBytes(stream.bytesAvailable));

                      stream.close();

                   

                  tourvid2.seek(document.timeleap);

                   

                  var xml2:XML = <dragAndDrop>

                                <timeleap>0</timeleap>

                                </dragAndDrop>;

                   

                    var file2:File = File.applicationStorageDirectory.resolvePath("videojump.xml");

                              var fileStream2:FileStream = new FileStream();

                              fileStream2.open(file2, FileMode.WRITE);

                              fileStream2.writeMultiByte(String(xml2), "iso-8859-01");

                              fileStream2.close();

                    }

                   

                  PS: I wrote to the 'videojump.xml' file a second time in 'Scene 2" to reset the value stored to '0' so the video would start at the beginning if the scene was navigated to directly.