使html5视频在结束时转到第一帧? [英] make html5 video go to first frame when it ends?

查看:969
本文介绍了使html5视频在结束时转到第一帧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的视频html5标记,绑定到已结束事件:

I have a simple video html5 tag, bound to an "ended" event:

$('#video').show().trigger("play").bind('ended', function () { 
//code
}

由于我通过点击按钮显示和隐藏这个,我想让它返回到最后一个函数的第一帧,所以它将从下一次出现时开始(现在它从结尾开始,当它从最后一帧到第一帧时会引起令人讨厌的闪烁)。

Since I'm "showing" and "hiding" this through a button click, I wanted to make it return to the first frame on that last function, so it would start from the beginning the next time it appears (right now it starts from the ending, and it causes a nasty flicker when it goes from the last to the first frame).

是可以用jQuery吗?

Is that possible with jQuery?

提前致谢!

推荐答案

你可以使用

$('#video').show().trigger("play").bind('ended', function () { 
    this.currentTime = 0;
}

如果已经过了loadedmetadata事件,则只能设置currentTime。

You can only set the currentTime if the loadedmetadata event has passed.

这篇关于使html5视频在结束时转到第一帧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆