1
我跟蹤一個計時器,我想以5秒爲間隔觸發。問題是 與我的Javascript math.round閾值
if (Math.round(time.position) % 5 === 0){do stuff}
測試觸發太多次了。它會觸發所有的9.〜十進制值。 如何以5秒爲間隔觸發?
time: Object {duration: 149.49, type: "jwplayerMediaTime", position: 9.29} index.html:104
time: Object {duration: 149.49, type: "jwplayerMediaTime", position: 9.43} index.html:104
time: Object {duration: 149.49, type: "jwplayerMediaTime", position: 9.54} index.html:104
time: Object {duration: 149.49, type: "jwplayerMediaTime", position: 9.68} index.html:104
time: Object {duration: 149.49, type: "jwplayerMediaTime", position: 9.79} index.html:104
time: Object {duration: 149.49, type: "jwplayerMediaTime", position: 9.92} index.html:104
time: Object {duration: 149.49, type: "jwplayerMediaTime", position: 10.03} index.html:104
time: Object {duration: 149.49, type: "jwplayerMediaTime", position: 10.18} index.html:104
time: Object {duration: 149.49, type: "jwplayerMediaTime", position: 10.29} index.html:104
time: Object {duration: 149.49, type: "jwplayerMediaTime", position: 10.42} index.html:104
time: Object {duration: 149.49, type: "jwplayerMediaTime", position: 10.54} index.html:104
time: Object {duration: 149.49, type: "jwplayerMediaTime", position: 10.68} index.html:104
time: Object {duration: 149.49, type: "jwplayerMediaTime", position: 10.79} index.html:104
time: Object {duration: 149.49, type: "jwplayerMediaTime", position: 10.92} index.html:104
time: Object {duration: 149.49, type: "jwplayerMediaTime", position: 11.04} index.html:104
time: Object {duration: 149.49, type: "jwplayerMediaTime", position: 11.17}
'setInterval(function(){...},5000);'是否足夠? – Mandera 2014-09-23 22:14:51
不,這是由視頻播放器定時器觸發的。 – seasick 2014-09-23 22:15:05
你必須跟蹤你已經覆蓋的職位。 – Pointy 2014-09-23 22:15:21