HTML5视频/ Jquery

编程入门 行业动态 更新时间:2024-10-27 00:32:04
HTML5视频/ Jquery - current.Time问题(HTML5 Video / Jquery - current.Time Issue)

我正在开展一个项目,我需要在一个视频中跳转到不同的时间,同时在指定的部分循环。

例如:视频A分为两部分,第一部分(1-10秒)和第二部分(11-20秒)。 最初,第一部分循环直到按下一个按钮,此时当前时间将跳转到第二部分,第二部分将在第二部分循环。

我的代码一直工作到按下按钮的程度。 该错误似乎与.bind()函数的使用有关,但我不确定。 这只是一个漏洞,直到错误发生。

$("#first").bind("timeupdate", function () { if (this.currentTime > 10) this.currentTime = 0; }); $('#hit').on('click', function () { $("#first").bind("timeupdate", function () { this.currentTime = 11; if (this.currentTime > 20) this.currentTime = 11; }); });

http://jsfiddle.net/jcLRe/17/

看完类似文章后,这似乎是一个常见问题。 感谢任何帮助。

-谢谢!

I'm working on a project where I need to jump to different times in a single video all while looping with in designated sections.

For example: Video A is divided into two parts, Part One (1-10 seconds) and Part Two (11 -20 seconds). Initially, Part One loops until a button is pressed, at which point current time will jump to Part Two which will loop within Part Two.

My code works up until the point where the button is pressed. The error seems to be related to the use of the .bind() function but I'm not sure. This is just an exerpt up until the point the error occurs.

$("#first").bind("timeupdate", function () { if (this.currentTime > 10) this.currentTime = 0; }); $('#hit').on('click', function () { $("#first").bind("timeupdate", function () { this.currentTime = 11; if (this.currentTime > 20) this.currentTime = 11; }); });

http://jsfiddle.net/jcLRe/17/

After looking at similiar articles, it seems this is a common issue. Appreciate any help.

-Thanks!

最满意答案

问题是$("#first")已经在this.currentTime > 10绑定。 因此,当您单击“命中”按钮并且this.currentTime = 11时,由于第一次绑定,它将再次变为0。 缪斯的回答是正确的。 如果你想切换Hit按钮再次从零开始播放。 只需将section = 2更改为

if(section == 1) section = 2; else section = 1;

The problem is $("#first") is already bind in this.currentTime > 10. So when you clicked the "Hit" button and this.currentTime = 11, it will turn to 0 again because of the first bind. Muse's answer is correct. And if you want to toggle the Hit button to play from zero again. Just change the section = 2 to

if(section == 1) section = 2; else section = 1;

更多推荐

本文发布于:2023-08-07 10:19:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1463675.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视频   Jquery

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!