actionscript-3apache-flexflash-builder4.5osmf

How to tell when OSMF player has finished Playing the video


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";
        }

Solution

  • You can try this:

    player.addEventListener(TimeEvent.COMPLETE, onComplete);