Getting "Time Elapsed" of a playing video from the YouTube API in ActionScript 3.0

Jimmery

I am building a YouTube video player in Flash / ActionScript 3.0, using their API.

However I am struggling to find a simple way of getting a play progress indicator. All I am looking for is a numerical display that shows time elapsed / total duration. It doesnt need to be a bar or anything.

After going through the YouTube API, I cant see any kind of event or method from which to get this kind of information.

Without any kind of event the best thing I can think of doing is creating a timer to mimick the time progress, pausing the timer when the video buffer event is triggered, but this seems a bit hacky and wrong.

What is the best way of getting the time elapsed data from the YouTube API?

SharpEdge

Yes in the Youtube API there are such informations:

player.getDuration():Number

Returns the duration in seconds of the currently playing video. Note that getDuration() will return 0 until the video's metadata is loaded, which normally happens just after the video starts playing.

If the currently playing video is a live event, the getDuration() function will return the elapsed time since the live video stream began. Specifically, this is the amount of time that the video has streamed without being reset or interrupted. In addition, this duration is commonly longer than the actual event time since streaming may begin before the event's start time.


player.getCurrentTime():Number

Returns the elapsed time in seconds since the video started playing.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related