javascript - How to detect change in youtube getCurrentTime()? -
is there way detect change of time in getcurrenttime() of youtube api?
purpose:to play single video limited time(<1 min) in page , move on next video.
i thinking use object.watch works variables not functions.
i try bind in original source code https://s.ytimg.com/yts/jsbin/www-widgetapi-vfl9twtxr.js complicated.
because youtube player wrapped in iframe, dependent on player exposes, , while they've exposed current time via getcurrenttime() function, haven't exposed events raised whenever time might updated (in fact, time updated exposed function 6 or 7 times per second, , isn't consistent).
so option set javascript timer. lots of ways that; simple 1 this:
setinterval(function(){ // here you'd raise sort of event based on value of getcurrenttime(); },100); // polling 8 times second, make sure every time changes.
as postmessage iframe isn't consistent, have interval timer greater. or use requestanimationframe poll 60 times second.
Comments
Post a Comment