如果视频 = 持续时间则停止并快退
我正在制作一个 HTML5 视频播放器。我想要它,以便当电影停止播放时这些执行
video.pause();
video.currentTime=0;
document.getElementById('message').innerHTML="Finished";
我尝试过,但它不起作用
function rewsi() {
var video = document.getElementsByTagName('video')[0];
if (video.currentTime==video.duration) {
video.pause();
video.currentTime=0;
document.getElementById('message').innerHTML="Finished";
}
}
有人找到了这个问题的解决方案吗? 问题 = 我缺乏 JavaScript 知识
I'm making a HTML5 video player. I want it so that when the movie stops the play these executes
video.pause();
video.currentTime=0;
document.getElementById('message').innerHTML="Finished";
I tried this but it didn't work
function rewsi() {
var video = document.getElementsByTagName('video')[0];
if (video.currentTime==video.duration) {
video.pause();
video.currentTime=0;
document.getElementById('message').innerHTML="Finished";
}
}
Anyone got a solution for this problem?
Problem = My lack of knowledge in JavaScript
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看以下问题和答案:
HTML5
我会指定一个回调在视频实际结束时执行,如下所示:
您还表示,当媒体“停止”时您想暂停视频,您能描述一下您这样做的动机吗?
议程上的下一个是视频重置,看起来您想将媒体的位置设置为开始,如果媒体停止,您必须首先确保您确定视频尚未暂停,就像您所做的那样如果用户已经去煮咖啡了,不想重置位置。
如果您只想在电影实际结束时设置媒体位置,那么这将毫无意义(除非您有充分的理由这样做),毫无意义的原因是当用户在电影结束后单击播放时, html5 媒体播放器的默认操作是将位置设置为 0。
上述解决方案应该完全适合您。
我建议使用 Kaltura HTML5 视频库来帮助您管理媒体播放器。
Looking at the following question and asnwer:
HTML5 <video> callbacks?
I would assign a callback to be executed when the video has actually ended like so:
You also stated that when the media 'stops' you want to pause the video, can you describe your motives for doing that ?
The next on the agenda is the video resetting as such, looks like you want to set the position of the media to the start if the media stops, you must first make sure that your determining that the video has not been paused, as you do not want to reset the position if the user has gone to make a cup of coffee.
If you only want to set the media position when the movie has actually ended then this would be pointless (unless you have a valid reason to do so), the reason it would be pointless is that when the user clicks play after it has ended, the default action html5 media player takes is to set the position to 0.
The above solution should work out exactly right for you.
i will recommend using Kaltura HTML5 Video Library to help you manage the media player.
首先,您只需在
video.ending
上设置一个条件即可检查视频是否已结束。然后您可以使用this.currentTime(0);
设置时间First, you can check if the video has ended by simply putting a condition on
video.ended
. Then you can set the time withthis.currentTime(0);