4 Replies Latest reply on Sep 18, 2009 7:57 PM by millydou

    why is my video not seekable?

    RossRitchey Level 4

      I am creating a video player using OSMF, built by integrating the various samples.


      Now, I have a MediaFactory that creates a VideoElement as the element of a MediaElementWrapper (sample class as component).


      The video plays fine (though it refuses to scale up to the space given)


      BUT - whenever I try to call any of the playback functions... (play, pause, seek) I get a RTE:


      Error: MediaPlayer - attempt to use a trait not on the media
           at org.openvideoplayer.media::MediaPlayer/getTrait()[C:\Dev\osmf\public\trunk\framework\MediaFramework\org\openvideoplayer\media\MediaPlayer.as:773]
           at org.openvideoplayer.media::MediaPlayer/seek()[C:\Dev\osmf\public\trunk\framework\MediaFramework\org\openvideoplayer\media\MediaPlayer.as:625]
           at com.adobe.strobe.players::MediaPlayerWrapper/seek()[F:\Program Files\Adobe\Strobe\apps\samples\adobe\MediaPlayer\src\com\adobe\strobe\players\MediaPlayerWrapper.as:444]
           at com.applied.flex.pages::VideoPage/seekPage()[K:\2077\Standards\Flash_Components\com\applied\flex\pages\VideoPage.as:132]
           at com.applied.flex.pages::VideoPage/startSeek()[K:\2077\Standards\Flash_Components\com\applied\flex\pages\VideoPage.as:102]
           at flash.events::EventDispatcher/dispatchEventFunction()
           at flash.events::EventDispatcher/dispatchEvent()
           at mx.core::UIComponent/dispatchEvent()[E:\dev\trunk\frameworks\projects\framework\src\mx\core\UIComponent.as:11597]
           at com.adobe.strobe.players::MediaPlayerWrapper/redispatchEvent()[F:\Program Files\Adobe\Strobe\apps\samples\adobe\MediaPlayer\src\com\adobe\strobe\players\MediaPlayerWrapper.as:522]
           at flash.events::EventDispatcher/dispatchEventFunction()
           at flash.events::EventDispatcher/dispatchEvent()
           at org.openvideoplayer.media::MediaPlayer/onPlayheadTimer()[C:\Dev\osmf\public\trunk\framework\MediaFramework\org\openvideoplayer\media\MediaPlayer.as:995]
           at flash.utils::Timer/_timerDispatch()
           at flash.utils::Timer/tick()


      That error is for the seek function.


      If I check the seekable it tells me its false.  Why is this?  I can't find any coherent documentation on how these classes actually work......

        • 1. Re: why is my video not seekable?
          RyanOConnell Level 2

          Hi Ross,


          I see that you are using the MediaPlayer, and are getting a trait not found exception.  This error is actually dependent on the media you have loaded into the MediaPlayer's source element.  Most media elements add the Seekable trait after load completes.   You can listen for load state changes on the mediaPlayers state property (or throught the loadable trait).  The MediaPlayer should auto load all media, so you should see it enter the loading phase, but enter the playback error phase at some point.


          To recieve these Playback errors, add the event listener to the MediaPlayer called MediaErrorEvent.MEDIA_ERROR.  The MediaError should contain more information about why your media has failed to load.  Here is some sample code (change the video url to something real):


          var mediaPlayer:MediaPlayer = new MediaPlayer();

          mediaPlayer.addEventListener(PlayerStateChangeEvent.MEDIA_PLAYER_STATE_CHANGE, onPlayerStateChange);

          mediaPlayer.addEventListener(MediaErrorEvent.MEDIA_ERROR, onMediaError);

          mediaPlayer.source = new VideoElement(new NetLoader(), new URLResource('http://exmaple.com/test.flv'));


          private function onPlayerStateChange(event:PlayerStateChangeEvent):void


               //your media player state watching code here.  See PlayerStateChangeEvent for more info



          private function onMediaError(event:PlayerStateChangeEvent):void


               //your media error handling code, ussually this means your urls is incorrect.


          1 person found this helpful
          • 2. Re: why is my video not seekable?
            RossRitchey Level 4

            Thanks for that.  Now the errors are gone, and now the video will play ok.


            With one exception.  The video refuses to actually seek.  The traces fire in the before and after seek functions, but the video always starts playing from 0 for some reason.


            Any thoughts?

            • 3. Re: why is my video not seekable?
              RossRitchey Level 4

              I figured out the seek problem


              I thought to myself: what if the video doesn't have the duration that I want to seek to when I try to seek?


              So I threw in a listener for durationChange, and discovered that the MediaPlayerStateChangeEvent fires before the DurationChangeEvent, causing my seek to happen on a video with a NaN duration.


              Changed the initial listener to watch for durationChange, rather than mediaPlayerStateChange, and it works as expected now.


              Thanks for the help.

              • 4. Re: why is my video not seekable?

                I als come upon the problem,perhaps the browser caused the phenomena,besides the speed of network is very very slow so that the video can not play properly,when the condition appear, I was very very angry, sometimes i change the browser,but if i do so,the effect is profoud, I will choose to shut off the computer.

                If you want to savvy more information about mobile phone, please come to http://www.nowsupplier.com/