Skip to main content
Participant
August 7, 2014
Answered

How do I get the timecode from a live streaming video?

  • August 7, 2014
  • 2 replies
  • 1084 views

Hi all!

I've setup a live streaming video that works fine.  On the server side, we are using The Flash Media Live Encoder streaming to Flash Media Server.   On the server, we have checked the box to add a "Timecode" to the video, and set that to just embed the system time.

On the client side, I have a SWF using the FLVPlayback component.  I can't seem to figure out how to get the Timecode value on the client.  "totalTime" return NaN and "playheadTime" just returns the number of seconds since the client connected.   I need to get the system time/timecode that is being embedded on the server.

Thanks!

This topic has been closed for replies.
Correct answer XavPaladin

FYI - I was able to do it by using the "onFI" handler of the embedded NetStream object.

myVideo.addEventListener(fl.video.VideoEvent.STATE_CHANGE, onVideoStateChange);

function onVideoStateChange(evt:fl.video.VideoEvent)

{

  // trace("State = " + evt.state);

  if ( evt.state == "playing" )

  {

  if (!ns)

  {

  ns = myVideo.getVideoPlayer(evt.vp).netStream;

  ns.client.onFI = onFIHandler;

  }

  }

}

function onFIHandler(infoObj:Object):void

{

  var ts:String = infoObj.st;

  trace("system time: " + ts);

  ExternalInterface.call("updateTimeStamp", ts);

}

2 replies

XavPaladinAuthorCorrect answer
Participant
August 8, 2014

FYI - I was able to do it by using the "onFI" handler of the embedded NetStream object.

myVideo.addEventListener(fl.video.VideoEvent.STATE_CHANGE, onVideoStateChange);

function onVideoStateChange(evt:fl.video.VideoEvent)

{

  // trace("State = " + evt.state);

  if ( evt.state == "playing" )

  {

  if (!ns)

  {

  ns = myVideo.getVideoPlayer(evt.vp).netStream;

  ns.client.onFI = onFIHandler;

  }

  }

}

function onFIHandler(infoObj:Object):void

{

  var ts:String = infoObj.st;

  trace("system time: " + ts);

  ExternalInterface.call("updateTimeStamp", ts);

}

Inspiring
August 8, 2014

If the embededd playheadTime gives you false results then start your own timer at the beginning of the video and get its content via currentCount.

//var ticker:timer = new Timer(1000);

ticker.addEventListener(TimerEvent.Timer, tickHandler);

function tickHandler(e:TimerEvent):{

   trace(e.currentCount);

   //outputs 1...2....3... as long as the movie runs every second

}