0

I have built a OSMF player info my mobile flex application but I can't find a way to tell when the video is done playing. Can I somehow tell when the video is completed?
Thanks in advance!

        import mx.core.UIComponent;

        import org.osmf.events.TimeEvent;

        import spark.components.Button;
        import spark.components.Group;


        public var playerInstance:StrobeMediaPlayback;
        public var grp:Group = new Group();
        protected function init(event:Event):void
        {

            _stage = systemManager.stage;
            _stage.align = StageAlign.TOP_LEFT;
            _parameters  =
                {
                    src:"assets/Mini film 2b with filter on.mp4"
                    , controlBarMode:"docked"
                    , controlBarAutoHide: true
                    , autoPlay: true
                    , playButtonOverlay:true
                    , showVideoInfoOverlayOnStartUp: true
                };

            var playerInstance:StrobeMediaPlayback = new StrobeMediaPlayback();
            playerInstance.initialize(_parameters, _stage, systemManager.loaderInfo, null);
            playerInstance = playerInstance;
            //playerInstance.addEventListener(, remove);
            var ui:UIComponent = new UIComponent();
            ui.addChild(playerInstance as DisplayObject);

            grp.percentWidth = 100;
            grp.percentHeight = 100;
            addElement(grp);
            grp.addElement(ui);
            actionBarVisible = false

        }

        private var urlLoader:URLLoader;
        private var urlRequest:URLRequest;
        private var loader:Loader;
        private var _stage:Stage;
        private var _parameters:Object;
        /* static */
        private static const ALLOW_LOAD_BYTES_CODE_EXECUTION:String = "allowLoadBytesCodeExecution";


        public function emptyCache():void
        {
            //playerInstance.player.pause();

            grp.removeAllElements();
            this.destructionPolicy = "auto";
        }
Anuj Balan
  • 7,629
  • 23
  • 58
  • 92
Justin
  • 1,249
  • 1
  • 15
  • 37
  • I actually am running into a similar issue. I am going to try a few things and I will post the result here after the fact. – Ben Roux Jun 04 '12 at 19:26
  • Thank you if i find something i will let you know. – Justin Jun 14 '12 at 19:35
  • I actually ended up having total success with using the TimeEvent.COMPLETE. It is working for streaming, psuedo streaming and basic progressive download (i am playing .mp4 and .f4f depending on the playback method). That said, you might want to edit the MediaPlayer.currentTimeUpdateInterval. – Ben Roux Jun 14 '12 at 19:56
  • Are your events not firing at the end of the video or is it firing prematurely? – Ben Roux Jun 14 '12 at 20:05
  • There aren't firing at all. It would get to the end and just sit there. – Justin Jun 14 '12 at 20:38
  • Have you tried adding the CURRENT_TIME_CHANGE event to see if that fires? If it does you should be able to check if( event.curentTime > player.duration ) { /* end video*/ } – Ben Roux Jun 14 '12 at 22:05

2 Answers2

2

You can try this:

player.addEventListener(TimeEvent.COMPLETE, onComplete);
Any Thing
  • 314
  • 3
  • 5
0
function onComplete() {
  console.log("Completed");
}

player.addEventListener("complete", onComplete);

API doc http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/org/osmf/events/TimeEvent.html

Sambhav
  • 11
  • 2