apiflashosmf

Get video progress of OSMF Player


A few years ago, Adobe had an OSMF video player wiki, and one of the examples on the wiki teaches on how to execute something for an specific ammount of time, while the video is playing using the javascript api's.

The wiki is no longer online, so I'm no longer able to access the example. How to get the current video time? I'm able to get currently the player status but not the video time. My code is below:

function onJavaScriptBridgeCreated(playerId){
                var player = document.getElementById(playerId);
                playerswf=document.getElementById(playerId);
                 var state = player.getState();
                 if(state=="playing"){
                     isplaying=1;
                    completeFunc();
                 }else{
                    isplaying=0;
                 }

      }

Solution

  • I think that you can do like this :

    player = document.getElementById(playerId);             
    player.addEventListener("currentTimeChange", "onCurrentTimeChange");
    
    function onCurrentTimeChange(time, playerId)
    {
        document.getElementById("currentTime").innerHTML = time;        
    }
    

    This code is a part of an OSMF working example which you can find here. There are many other examples attached to the source code which you can download from sourceforge.

    Hope that can help.