2 Replies Latest reply on Jul 14, 2010 10:44 AM by weizhangstrobe

    Pseudo Streaming OSMF question




      I am currently building a player for a client what they need to do is to connect to a server over HTTP and stream back an FLV video file. They have implemented some server side code to allow seeking to a later part of the file. I have a couple of questions around how to build my player to support this.


      I have created a simple player which connects to the service and gets the video and starts playing it in the first instance, no problems there. I guess my first question is around the order in which to do things to successfully start playing from the new point. I am first using mediaPlayer.pause() to stop the video then calling out to the getPartialVideo service on the server giving a byte offset. As far as i can tell this is returning data but when i try mediaPlayer.play() it is not playing the video. Is this because i need to use mediaPlayer.seek to take the player to the new part of the video that i am now streaming from? If so then is there a way to get the bytes per second as the seek method takes a time parameter not a byte offset?







        • 1. Re: Pseudo Streaming OSMF question
          arayne Level 1



          So I have a little more detail on my question now. I have a videoElement which goes and gets me the video from the beginning in the first instance. I get the metadata from this and build a list of the keyframes. I then send a request to the server by changing the videoElements URLResource to point to the url for the getPartialVideo service i have and give it the "?start=byteoffset" number of the keyframe i want to jump to. This goes to the server and seems to return without any errors. When the next mediaplayercapabilitiesChangedEvent fires i check if the player can play and then play it. However visually my player is still paused.



          Any idea's greatfully received.







          code below:


          So initially i call his giving the byteoffset in the url as 0. This returns and plays the video fine.


          private function playVideoURL():void 

          mediaPlayer.addEventListener( MediaPlayerCapabilityChangeEvent.CAN_PLAY_CHANGE, onVideoLoadedAndReady );

          mediaPlayer.addEventListener( MediaPlayerCapabilityChangeEvent.CAN_SEEK_CHANGE, onCanSeekChange ); 

          mediaPlayer.addEventListener( MediaPlayerCapabilityChangeEvent.HAS_DISPLAY_OBJECT_CHANGE, hasDispObjChanged );

          mediaPlayer.addEventListener( DisplayObjectEvent.MEDIA_SIZE_CHANGE, onDimensionChange ); 


                          videoElement = new VideoElement( new URLResource( url+0 ), new HTTPStreamingNetLoader() ); 


                          mediaPlayer.media = videoElement; 


          mediaPlayer.displayObject.width = videoWidth; 

          mediaPlayer.displayObject.height = videoHeight; 

          mediaHolder.addChild( mediaPlayer.displayObject );


          mediaHolder.addChild( playerContainer ); 



          On canSeekChange is where i add a handler to get the metadata.


          private function onCanSeekChange( event:MediaPlayerCapabilityChangeEvent ):void


          trace("CAN_SEEK EVENT FIRED");

          canSeek = true;

          bytesTotal = mediaPlayer.bytesTotal;


          videoElement.client.addHandler("onMetaData", onMetaData);



          This method see's that the video is ready to play and plays it. This is where it is not playing when i get the second offset


          private function onVideoLoadedAndReady(event:MediaPlayerCapabilityChangeEvent):void 

                          if (event.enabled  && mediaPlayer.canPlay) 




          This is where i suspect i have some bits missing and am not doing something with the player to set it to play when it gets the new stream?


          private function seekHandler(event:Event):void



          url = url + skipTo.text;

          videoElement.resource = new URLResource( url );


          • 2. Re: Pseudo Streaming OSMF question
            weizhangstrobe Level 2



            Would you please send me the complete project such that I can do some debugging for you? I am an OSMF developer at Adobe and more than happy to help you out on this. You may contact me directly via my company email weizhang@adobe.com.


            -Wei Zhang

            Senior Computer Scientist

            Adobe Systems