admin管理员组文章数量:1305749
I am trying to implement a course portal where videos will be uploaded locally and will be available to students for studying. I am trying to create a interactive system: which will produce a question when the video reaches at a particular time.
For this I am using 'video-js' plugin for flash and HTML5 player. Now what I want to do is keeping track of time of video. Hence when the video reaches a particular time, I will be able to make a ajax call showing the question at particular time.
For this I am using 'durationchange' of video-js plugin. But it's only giving the 0th second as shown in following code
video1 = videojs('mplayer');
video1.on('durationchange', event);
var video1 = function(){
currentTime = video1.currentTime; // nothing
}
How should I go about it. Please help me. Thanx.
I am trying to implement a course portal where videos will be uploaded locally and will be available to students for studying. I am trying to create a interactive system: which will produce a question when the video reaches at a particular time.
For this I am using 'video-js' plugin for flash and HTML5 player. Now what I want to do is keeping track of time of video. Hence when the video reaches a particular time, I will be able to make a ajax call showing the question at particular time.
For this I am using 'durationchange' of video-js plugin. But it's only giving the 0th second as shown in following code
video1 = videojs('mplayer');
video1.on('durationchange', event);
var video1 = function(){
currentTime = video1.currentTime; // nothing
}
How should I go about it. Please help me. Thanx.
Share Improve this question asked Dec 30, 2013 at 14:13 phenom_aksphenom_aks 774 silver badges11 bronze badges1 Answer
Reset to default 10you actually need to be using the timeupdate
event - durationchange
is only fired if the duration of the video changes (usually when metadata finishes loading)
you can then track that currentTime property for the video:
using basic javascript
<video id="video" preload="auto" loop autoplay controls muted>
<source src="bigbuck.m4v" type='video/mp4' />
</video>
<div id="timer"> </div>
<script>
document.getElementById("video").addEventListener('timeupdate', function() {
document.getElementById("timer").innerHTML = this.currentTime;
currentTime = this.currentTime;
});
</script>
本文标签: javascriptVideojsGetting timestamp of video dynamicallyStack Overflow
版权声明:本文标题:javascript - Videojs : Getting timestamp of video dynamically - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741808655a2398660.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论