Video.js:最后显示大播放按钮

EMG*_*EMG 6 video.js

我想在视频结尾处显示大播放按钮,以便用户可以轻松地重播.

看来默认显示这个大的播放按钮(我读过的每个帖子都是为了隐藏它而不是显示它...),但对我来说情况并非如此......

我试图编辑以下函数(在video.dev.js文件中)但没有任何改变:

vjs.Player.prototype.onEnded = function(){
  if (this.options_['loop']) {
      this.currentTime(0);
      this.play();
  }
  else {  // I am not using loop mode
      this.bigPlayButton.show();
      this.pause();
  }
};
Run Code Online (Sandbox Code Playgroud)

谢谢你的回复.

mis*_*ben 9

有几种方法可以做到这一点.您可以在视频以API结尾时显示该按钮:

videojs("myPlayer").ready(function(){
  var myPlayer = this;
  myPlayer.on("ended", function(){
    myPlayer.bigPlayButton.show();
  });
});
Run Code Online (Sandbox Code Playgroud)

或者,如果您确实想要修改video.dev.js,只需要取消注释执行相同操作的行:

vjs.BigPlayButton = vjs.Button.extend({
  /** @constructor */
  init: function(player, options){
    vjs.Button.call(this, player, options);

    if (!player.controls()) {
      this.hide();
    }

    player.on('play', vjs.bind(this, this.hide));
    // player.on('ended', vjs.bind(this, this.show)); // uncomment this
  }
});
Run Code Online (Sandbox Code Playgroud)

或者使用CSS,您可以在视频未播放(结束或暂停)时强制显示按钮:

.video-js.vjs-default-skin.vjs-paused .vjs-big-play-button {display:block !important;}
Run Code Online (Sandbox Code Playgroud)

您看到的关于隐藏它的帖子可能是指video.js的第3版,因为最后显示了播放按钮.