有没有办法“寻求”在使用JavaScript的视频中的某个时间? [英] Is there a way to "seek" to a certain time in a video using JavaScript?

查看:94
本文介绍了有没有办法“寻求”在使用JavaScript的视频中的某个时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带视频的iframe,例如:

 < iframe src =http:// player。 vimeo.com/video/18150336width =500height =281frameborder =0webkitallowfullscreen mozallowfullscreen allowfullscreen>< / iframe> 

来源不一定是vimeo,可以是YouTube,BrightCove,Hulu等。



有没有一种方法可以使用jQuery / JavaScript在视频中查找某个时间?例如,如果我想访问视频中的3:41,我是否可以编写代码来自动寻找那段时间,而无需API访问提供视频的网站?

解决方案

当然。您可以使用VideoJS。您可能很难控制iFrame。据说,您可以使用VideoJS嵌入各种视频托管网站的视频。

 < script> 
VideoJS.DOMReady()函数(){
var player = VideoJS.setup(current_video);
player.play();
player.currentTime(666);
});
< / script>

ref:

https://github.com/zencoder/video-js/blob /df41661f47201cfbc979b1fbba68fba3d67c06b0/dev/src/tech/youtube.js



http://videojs.com/



https://github.com/zencoder/video-js/blob/master/docs/api.md


I have an iframe with a video, for example:

<iframe src="http://player.vimeo.com/video/18150336" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>

The source won't always be vimeo, it can be YouTube, BrightCove, Hulu etc etc.

Is there a way to use jQuery/JavaScript to "seek" to a certain time in the video? For example, if I wanted to get to 3:41 inside of a video could I write code to automatically seek to that time w/o API access to the sites providing the video?

解决方案

Sure. You can use VideoJS. You may have a hard time getting control of the iFrame as you put it. You can embed various video hosting sites' video with VideoJS, supposedly.

<script>
VideoJS.DOMReady(function() {
var player = VideoJS.setup("current_video");
player.play();
player.currentTime(666);
});
</script>

ref:

https://github.com/zencoder/video-js/blob/df41661f47201cfbc979b1fbba68fba3d67c06b0/dev/src/tech/youtube.js

http://videojs.com/

https://github.com/zencoder/video-js/blob/master/docs/api.md

这篇关于有没有办法“寻求”在使用JavaScript的视频中的某个时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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