use jwplayer to get current play time

wumengjun picture wumengjun · May 15, 2012 · Viewed 13k times · Source

I am using jwplayer to play embedded video, the javascript api tells me

jwplayer("mediaplayer").getPosition()

will get the current position, but my result is undefined

Can anyone help me get the correct resilts

Answer

Manse picture Manse · May 15, 2012

Works fine for me just how the documentation specifies :

<div id="container"></div>


jwplayer("container").setup({
    file: "http://content.bitsontherun.com/videos/nPripu9l-60830.mp4",
    flashplayer: "http://player.longtailvideo.com/player.swf",
    image: "http://content.bitsontherun.com/thumbs/nPripu9l-480.jpg",
    height: 270,
    width: 480
});
var state = jwplayer("container").getState();
var elapsed = jwplayer("container").getPosition();