javascript - Does YouTube iframe API have an event that fires continuously during playback? -
javascript - Does YouTube iframe API have an event that fires continuously during playback? -
i'm using youtube iframe api implement video player.
i'd able subscribe event fires periodically during playback. example, every 10 seconds, i'd capture , log current playback time of video.
the iframe api exposes events onplayerready , onstatechange, don't tell me video while it's playing.
i'm not finding answers in google's documentation. ideas?
thanks!
i answered own question--you can utilize setinterval within onstatechange iframe api event this:
function onplayerstatechange( if (event.data === yt.playerstate.playing) { refresh_interval_id = setinterval(function () { var duration = videoplayer.getduration(); var current_time = videoplayer.getcurrenttime(); }, 3000); } else if (event.data === yt.playerstate.paused || event.data === yt.playerstate.ended) { clearinterval(refresh_interval_id); } }
javascript video youtube
Comments
Post a Comment