zzh*_*lyc 2 iphone ios video.js
其他还可以,但设置为currentTime:
我尝试了一些类似的方法:
videojs("example_video_1", {}, function() {
this.currentTime(200);
this.play();
});
Run Code Online (Sandbox Code Playgroud)
这是行不通的。
videojs("example_video_1").ready(function(){
this.currentTime(200);
});
Run Code Online (Sandbox Code Playgroud)
这也不起作用。
var dom = document.getElementById('example_video_1');
dom.addEventListener("loadedmetadata", function() {
dom.currentTime = 100;
}, false); // ok for no video.js
videojs(dom);
Run Code Online (Sandbox Code Playgroud)
不工作 甚至颠倒了addEventListener和初始化videojs的路线。
我尝试了videojs事件。
var player = videojs("example_video_1");
alert(player.addEvent);
alert(player.addEventListener);
Run Code Online (Sandbox Code Playgroud)
这些API都不存在,因此如何绑定Event videojs?
这是我在启动时将视频播放到指定位置的方式(它消除了视频首先开始并且随后才跳转到视频位置的问题):
$(document).ready(function()
{
var timecode = 120;
var initdone = false;
// wait for video metadata to load, then set time
video.on("loadedmetadata", function(){
video.currentTime(timecode);
});
// iPhone/iPad need to play first, then set the time
// events: https://www.w3.org/TR/html5/embedded-content-0.html#mediaevents
video.on("canplaythrough", function(){
if(!initdone)
{
video.currentTime(timecode);
initdone = true;
}
});
}); // END ready
Run Code Online (Sandbox Code Playgroud)
哦,幸运的是,我在https://github.com/videojs/video.js中找到了一个示例
var dom = document.getElementById('example_video_1');
videojs(dom, {}, function(){
this.on('loadedmetadata', function(){
this.currentTime(500);
});
});
Run Code Online (Sandbox Code Playgroud)
这是工作,绑定事件的API是player.on('event', fn);
videojs 很酷~