我需要在vimeo embeded播放器上禁用搜索。似乎唯一的答案是在搜索事件上使用setCurrentTime。问题是它被抛入无限循环。也许是因为timeupdate也会在搜索中被触发。
this.player.on('timeupdate', this.vimeoPlayProgress.bind(this));
this.player.on('seeked', this.vimeoSeek.bind(this));
然后在vimeoSeek:
var player = this.player;
var playTime = this.vimeoPlayTime;
player.setCurrentTime(playTime).then(function (seconds) {
...
});
答案 0 :(得分:0)
我尝试了如下,但在缓冲时间内存在问题,如下所述:https://github.com/vimeo/player.js/issues/61
var player = new Vimeo.Player(iframe);
var priorTimeUpdateTime = 0;
player.on('seeked', function() {
player.pause().then(function(){
player.getCurrentTime().then(function(seconds) {
//console.log('seconds: '+ seconds + ' priorTimeUpdateTime: ' + priorTimeUpdateTime);
if (seconds > priorTimeUpdateTime) {
player.setCurrentTime(priorTimeUpdateTime).then(function(seconds) {
// seconds = the actual time that the player seeked to
}).catch(function(error) {
switch (error.name) {
case 'RangeError':
// the time was less than 0 or greater than the video’s duration
break;
default:
// some other error occurred
break;
}
});
}
}).catch(function(error) {
// an error occurred
console.log('Vimeo API error');
});
});
player.play();
});
player.on('ended', function() {
alert('Do something at the end!');
});
setInterval(function() {
player.getCurrentTime().then(function(seconds2) {
priorTimeUpdateTime = seconds2;
//console.log('Playhead Update: ' + priorTimeUpdateTime);
}).catch(function(error) {
// an error occurred
console.log('Vimeo API error');
});
}, 15000)