admin管理员组文章数量:1023195
I've noticed a small inconsistency that I'm hoping to verify as either a quirk of HTML5, or something specific to Video.js.
It seems that if you call Video.js' currentTime()
function whilst providing a new time, any further calls to currentTime()
(to get the current time) will not return the correct time (it will return the previous time), until the timeupdate
event fires. After the timeupdate
event, currentTime()
will return the correct time.
For example, assuming the video hasn't started playing yet, but Video.js has loaded, along with all the video meta etc:
videoPlayer.addEvent('timeupdate', function() {
console.log('Event callback: ' + player.currentTime);
});
console.log('Original time: ' + player.currentTime);
player.currentTime(100);
console.log('New time: ' + player.currentTime);
The output I was expecting would look like:
Original time: 0
New time: 100
Event callback: 100
However what I've receiving is:
Original time: 0
New time: 0
Event callback: 100
Any insight would be fantastic!
Edit: I can reproduce this in Chrome and Safari on OSX, but not Firefox on OSX (all using HTML5). I can also reproduce this on IE8 using the Flash player and IE9 using the HTML5 player.
I've noticed a small inconsistency that I'm hoping to verify as either a quirk of HTML5, or something specific to Video.js.
It seems that if you call Video.js' currentTime()
function whilst providing a new time, any further calls to currentTime()
(to get the current time) will not return the correct time (it will return the previous time), until the timeupdate
event fires. After the timeupdate
event, currentTime()
will return the correct time.
For example, assuming the video hasn't started playing yet, but Video.js has loaded, along with all the video meta etc:
videoPlayer.addEvent('timeupdate', function() {
console.log('Event callback: ' + player.currentTime);
});
console.log('Original time: ' + player.currentTime);
player.currentTime(100);
console.log('New time: ' + player.currentTime);
The output I was expecting would look like:
Original time: 0
New time: 100
Event callback: 100
However what I've receiving is:
Original time: 0
New time: 0
Event callback: 100
Any insight would be fantastic!
Edit: I can reproduce this in Chrome and Safari on OSX, but not Firefox on OSX (all using HTML5). I can also reproduce this on IE8 using the Flash player and IE9 using the HTML5 player.
Share Improve this question edited May 13, 2013 at 2:07 Lachlan McDonald asked May 13, 2013 at 1:51 Lachlan McDonaldLachlan McDonald 2,4342 gold badges24 silver badges26 bronze badges1 Answer
Reset to default 2I've seen similar behaviour on several other html5/flash players.
I've always been under the assumption that even after seeking via currentTime(100);
, the playhead will not be updated until the next timeupdate
event.
I've noticed a small inconsistency that I'm hoping to verify as either a quirk of HTML5, or something specific to Video.js.
It seems that if you call Video.js' currentTime()
function whilst providing a new time, any further calls to currentTime()
(to get the current time) will not return the correct time (it will return the previous time), until the timeupdate
event fires. After the timeupdate
event, currentTime()
will return the correct time.
For example, assuming the video hasn't started playing yet, but Video.js has loaded, along with all the video meta etc:
videoPlayer.addEvent('timeupdate', function() {
console.log('Event callback: ' + player.currentTime);
});
console.log('Original time: ' + player.currentTime);
player.currentTime(100);
console.log('New time: ' + player.currentTime);
The output I was expecting would look like:
Original time: 0
New time: 100
Event callback: 100
However what I've receiving is:
Original time: 0
New time: 0
Event callback: 100
Any insight would be fantastic!
Edit: I can reproduce this in Chrome and Safari on OSX, but not Firefox on OSX (all using HTML5). I can also reproduce this on IE8 using the Flash player and IE9 using the HTML5 player.
I've noticed a small inconsistency that I'm hoping to verify as either a quirk of HTML5, or something specific to Video.js.
It seems that if you call Video.js' currentTime()
function whilst providing a new time, any further calls to currentTime()
(to get the current time) will not return the correct time (it will return the previous time), until the timeupdate
event fires. After the timeupdate
event, currentTime()
will return the correct time.
For example, assuming the video hasn't started playing yet, but Video.js has loaded, along with all the video meta etc:
videoPlayer.addEvent('timeupdate', function() {
console.log('Event callback: ' + player.currentTime);
});
console.log('Original time: ' + player.currentTime);
player.currentTime(100);
console.log('New time: ' + player.currentTime);
The output I was expecting would look like:
Original time: 0
New time: 100
Event callback: 100
However what I've receiving is:
Original time: 0
New time: 0
Event callback: 100
Any insight would be fantastic!
Edit: I can reproduce this in Chrome and Safari on OSX, but not Firefox on OSX (all using HTML5). I can also reproduce this on IE8 using the Flash player and IE9 using the HTML5 player.
Share Improve this question edited May 13, 2013 at 2:07 Lachlan McDonald asked May 13, 2013 at 1:51 Lachlan McDonaldLachlan McDonald 2,4342 gold badges24 silver badges26 bronze badges1 Answer
Reset to default 2I've seen similar behaviour on several other html5/flash players.
I've always been under the assumption that even after seeking via currentTime(100);
, the playhead will not be updated until the next timeupdate
event.
本文标签: javascriptvideojs currentTime() incorrect until timeupdate event firesStack Overflow
版权声明:本文标题:javascript - video.js currentTime() incorrect until timeupdate event fires - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745543784a2155301.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论