2 Replies Latest reply on Aug 5, 2010 6:51 AM by leaflashdev

    Detect If the video is loaded

    leaflashdev

      Hello

       

      I want to detect whenever the video is loaded

      because I display a png of the first frame of the video , when the video start to play I want to remove the image, try to do a smooth effect

       

      Here is my code to load the video

       

      var netLoader:NetLoader = new NetLoader();
      var resource = new URLResource( url )
      var metadata:Metadata = new Metadata();
                               
      metadata.addValue(CaptioningPluginInfo.CAPTIONING_METADATA_KEY_URI, CAPTION_URL);
      resource.addMetadataValue(CaptioningPluginInfo.CAPTIONING_METADATA_NAMESPACE, metadata);
      mediaFactory.addItem(new MediaFactoryItem("org.osmf.elements.video", netLoader.canHandleResource, createVideoElement));
      mediaElement = mediaFactory.createMediaElement(resource);

       

      I don't know where to add the listener to know if the video is ready

       

       

      Thanks for you help

        • 1. Re: Detect If the video is loaded
          weizhangstrobe Level 2

          I believe you also use an instance of MediaPlayer and this is the object that you need to listen for its

          mediaPlayerStateChange of the MediaPlayerStateChangeEvent

          The values for the player state can be found at PlayState.as.

           

          -Wei Zhang

          Senior Computer Scientist

          Adobe Systems, Inc.

          weizhang@adobe.com

          • 2. Re: Detect If the video is loaded
            leaflashdev Level 1

            Thank you very much it works !

             

            mediaPlayer.addEventListener( MediaPlayerStateChangeEvent.MEDIA_PLAYER_STATE_CHANGE, onLoaderStateChange );

             

             

            private function onLoaderStateChange( e:MediaPlayerStateChangeEvent = null ) :void
                            {
                                trace('onLoaderStateChange')
                                if(e.state == "ready"){
                                    trace('ready')
                                }
                                if(e.state == "uninitialized"){
                                    trace('uninitialized')
                                }
                            }