11 Replies Latest reply on Dec 17, 2009 10:27 AM by jerryhamby

    Trying to get started with OSMF

    lisamarienyc

      I'm putting together a very basic example to get people started with OSMF, to demonstrate how to play a video and listen for some events, just in an AS3 class in Flash CS4. Having some trouble. I've referenced as many examples as I can find, and have come up with the following example which initializes, but then does nothing. No errors thrown.  I am a bit rusty, to be honest, so it's likely something simple... Any help or advice greatly appreciated. (also attached source)

       

      package {

       

      import flash.display.Sprite;
      import org.openvideoplayer.events.LoadableStateChangeEvent;
      import org.openvideoplayer.events.MediaPlayerCapabilityChangeEvent;
      import org.openvideoplayer.media.MediaPlayer;
      import org.openvideoplayer.media.URLResource;
      import org.openvideoplayer.net.NetLoader;
      import org.openvideoplayer.traits.ILoadable;
      import org.openvideoplayer.traits.LoadState;
      import org.openvideoplayer.traits.MediaTraitType;
      import org.openvideoplayer.video.VideoElement;
      import org.openvideoplayer.utils.URL;

       

      public class OSMFExampleTwo extends Sprite {

       

          private const PROGRESSIVE:String = "tyra-clip_1_VP6_768K.flv";
          private var _player:MediaPlayer;
         
          public function OSMFExampleTwo() {
              trace("initialized");
              _player = new MediaPlayer();
              _player.addEventListener( MediaPlayerCapabilityChangeEvent.VIEWABLE_CHANGE, onViewable );
              _player.source = new VideoElement( new NetLoader(), new URLResource(new URL(PROGRESSIVE)));

              var loadable:ILoadable = _player.source.getTrait( MediaTraitType.LOADABLE ) as ILoadable;
              loadable.addEventListener( LoadableStateChangeEvent.LOADABLE_STATE_CHANGE, onLoaded );
              }
             
              private function onLoaded( e:LoadableStateChangeEvent ) :void {
                  if( e.newState == LoadState.LOADED ) {
                  trace( 'load completed' );
                  } else if( e.newState == LoadState.LOAD_FAILED ) {
                  trace( 'load failed' );
                  }
              }
             
              private function onViewable( e:MediaPlayerCapabilityChangeEvent ) :void {
                  if( e.enabled ) {
                      addChild( _player.view );
                      trace('player view');
                  }
              }
          }
      }

       

        • 1. Re: Trying to get started with OSMF
          Edwin van Rijkom

          Hi Lisa,

           

          Thanks for trying out the framework! I think the problem is with the local path that you are specifying. If I replace it by a fully qualified one like so:

           

          private const PROGRESSIVE:String = "file://localhost/Users/edwin/Downloads/osmfexample/tyra-clip_1_VP6_768K.flv";

           

          then things work. I see no reason why the load state change handler shouldn't be signaling 'LOAD_FAILED' though. It'd be great if you could log a bug on that at http://bugs.adobe.com/jira/ under the 'Strobe' project.

           

          Cheers,

          Edwin

           

          PS: the movie you included seems to be blank, audio only?

          1 person found this helpful
          • 2. Re: Trying to get started with OSMF
            RyanOConnell Level 2

            There is a bug with out relative path handling for URLs on the URLResource.  If you specify your video with a leading "./", like this  : "./tyra-clip_1_VP6_768K.flv"  it should load the video.  You could also use direct http:// or file:// style urls for local files.  Thanks for the feedback!

             

            Ryan O'Connell

            OSMF Engineering

            1 person found this helpful
            • 3. Re: Trying to get started with OSMF
              lisamarienyc Level 1

              Great! This does get a video to load, but its not autoplaying. Isn't that the default behavior?

               

              Thanks

              // Lisa

              • 4. Re: Trying to get started with OSMF
                Edwin van Rijkom Level 2

                Yes, that's the default behavior.

                 

                It did automatically start playing just now when I tried your sample - but we might be on a different version of the framework (I was building from the trunk). If that's not the case, then it'd be great if you could log it as a bug!

                 

                Cheers,

                Edwin

                • 5. Re: Trying to get started with OSMF
                  lisamarienyc Level 1

                  Actually, I'm now realizing that the sound is playing, but the video is just a black frame.
                  I'll log a bug.

                  Glad it's not me!


                  Thanks for the help.

                  // Lisa Larson-Kelley

                  • 6. Re: Trying to get started with OSMF
                    Edwin van Rijkom Level 2

                    Ah - yes, I'd noticed that too - but I believe this is your FLV. If I play it back with VLC, example, it shows black too. Could you make sure it is not your FLV before you submit?

                     

                    Thanks!

                    Edwin

                    • 7. Re: Trying to get started with OSMF
                      lisamarienyc Level 1

                      Yep. You're right. I tested a different video and it works fine. Hurrah!

                       

                      Thank you!

                      • 8. Re: Trying to get started with OSMF
                        Edwin van Rijkom Level 2

                        That's great to hear - thanks for letting us know!

                         

                        Cheers,

                        Edwin

                        • 9. Re: Trying to get started with OSMF
                          jerryhamby

                          Is this bug fixed in Sprint 8? I'm using Sprint 7 and I can only get the first image to load and become visible.

                           

                          Here are some tests I ran:

                           

                          ====== this works, and I can view every image one at a time, this is NOT a slideshow  =======

                          pImageSerialElement = new SerialElement();

                          pImageSerialElement.addChild(new ImageElement(new ImageLoader(),new URLResource(new URL("images/image4.jpg"))));

                          pImageSerialElement.addChild(new ImageElement(new ImageLoader(),new URLResource(new URL("images/image2.png"))));

                          pImageSerialElement.addChild(new ImageElement(new ImageLoader(),new URLResource(new URL("images/image3.png"))));

                           

                          ====== this works a little    image1=loaded, image2=loadFailed,  image3=loadFailed =======

                          pImageSerialElement = new SerialElement();

                          pImageSerialElement.addChild(new TemporalProxyElement(3, new ImageElement(new ImageLoader(), new URLResource(new URL("images/image4.jpg")))));

                          pImageSerialElement.addChild(new TemporalProxyElement(3, new ImageElement(new ImageLoader(), new URLResource(new URL("images/image2.jpg")))));

                          pImageSerialElement.addChild(new TemporalProxyElement(3, new ImageElement(new ImageLoader(), new URLResource(new URL("images/image3.jpg")))));

                           

                          ====== does not work at all   image1= loadFailed, image2=loadFailed,  image3=loadFailed  =======

                          ====== TemporalProxyElement =======

                          ... new URLResource(new URL("/images/image4.jpg")))));

                          … new URLResource(new URL("/images/image2.jpg")))));

                          … new URLResource(new URL("/images/image3.jpg")))));

                           

                          ====== does not work at all   image1= loadFailed, image2=loadFailed,  image3=loadFailed  =======

                          ====== TemporalProxyElement =======

                          ... new URLResource(new URL("./images/image4.jpg")))));

                          … new URLResource(new URL("./images/image2.jpg")))));

                          … new URLResource(new URL("./images/image3.jpg")))))

                           

                          ====== does not work at all   image1= loadFailed, image2=loadFailed,  image3=loadFailed  =======

                          ====== TemporalProxyElement =======

                          ... new URLResource(new URL("../images/image4.jpg")))));

                          … new URLResource(new URL("../images/image2.jpg")))));

                          … new URLResource(new URL("../images/image3.jpg")))))

                           

                           

                          ====== does not work at all  image1= loadFailed, image2=loadFailed,  image3=loadFailed  ======= I'm on a Mac

                          ====== TemporalProxyElement =======

                          … new URLResource(new URL("MacProTera/OSMF/Version5/images/image4.jpg")))));

                          … new URLResource(new URL("MacProTera/OSMF/Version5/images/image2.jpg")))));

                          … new URLResource(new URL("MacProTera/OSMF/Version5/images/image3.jpg")))));

                           

                           

                          ====== this works a little,image1=loaded, image2=loadFailed,  image3=loadFailed ======= I'm on a Mac

                          ====== TemporalProxyElement =======

                          … new URLResource(new URL("MacProTera:OSMF:Version5:images:image4.jpg")))));

                          ... new URLResource(new URL("MacProTera:OSMF:Version5:images:image2.jpg")))));

                          … new URLResource(new URL("MacProTera:OSMF:Version5:images:image3.jpg")))));

                          • 10. Re: Trying to get started with OSMF
                            bringrags Level 4

                            The first two cases work fine for me.  Is it possible you have the wrong URL in the second example?  I noticed that the extension is PNG in the first case, and JPG in the second.

                            • 11. Re: Trying to get started with OSMF
                              jerryhamby Level 1

                              Good catch, it was the naming problem. The nasty copy/paste strikes again!