Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript mediaelement.js-防止向前搜索/允许向后搜索_Javascript_Mediaelement.js - Fatal编程技术网

Javascript mediaelement.js-防止向前搜索/允许向后搜索

Javascript mediaelement.js-防止向前搜索/允许向后搜索,javascript,mediaelement.js,Javascript,Mediaelement.js,你能给我一个想法或样本,我可以阻止向前搜索到搜索栏,但允许向后搜索吗 这是我发现的,但它一直在循环: media.addEventListener('seeked', function(e) { // player.setCurrentTime(0); // player.play(); }, true); 我所做的是:在未压缩版本的mediaelement库中查找一行: media.setCurrentTime(新时间) 在上一行上方添加: if(new

你能给我一个想法或样本,我可以阻止向前搜索到搜索栏,但允许向后搜索吗

这是我发现的,但它一直在循环:

media.addEventListener('seeked', function(e) {           
    // player.setCurrentTime(0);
    // player.play();
}, true);

我所做的是:在未压缩版本的mediaelement库中查找一行: media.setCurrentTime(新时间)

在上一行上方添加:
if(newTime我所做的是:在未压缩版本的mediaelement库中查找一行: 媒体。设置当前时间(newTime);

在上一行上方添加:
if(newTime我最近也有同样的要求

但是我真的不想修改源文件

以下是不修改源代码的另一种方法:

  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
      }
  };

var _player=$(“#我的视频_1”)[0].player;//我最近也有同样的要求

但是我真的不想修改源文件

以下是不修改源代码的另一种方法:

  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
      }
  };
var _player=$(“#我的视频_1”)[0]。播放器//