您能否给我一个想法或样本,我可以防止向前搜索到搜索栏但允许向后搜索?
这是我发现的,但它一直在循环:
media.addEventListener('seeked', function(e) {
// player.setCurrentTime(0);
// player.play();
}, true);
您能否给我一个想法或样本,我可以防止向前搜索到搜索栏但允许向后搜索?
这是我发现的,但它一直在循环:
media.addEventListener('seeked', function(e) {
// player.setCurrentTime(0);
// player.play();
}, true);
我最近有同样的要求。
但并不想修改源文件。
这是另一种不修改源代码的方法:
var _player = $("#my_video_1")[0].player; //<-- get the reference to the player
old = _player.media.setCurrentTime; //<-- store the native setCurrentTime temporarily
_player.media.setCurrentTime = function(time) { //<-- override it with our own method
if(time <= this.currentTime){
old.apply(this,[time]); //<-- call the stored method if our conditions are met
}
};
我所做的是:在 mediaelement 库的未压缩版本中找到一行: media.setCurrentTime(newTime);
在上一行上方添加: if ( newTime <= media.currentTime )
最终你有:
if ( newTime <= media.currentTime )
media.setCurrentTime(newTime);
这意味着如果要搜索的时间小于或等于玩家的当前时间,则允许搜索。