javascript brightcove.js

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript brightcove.js相关的知识,希望对你有一定的参考价值。

// Get a reference to the player
var myPlayer = videojs("S1LnMbpBz"),
  options = {};

// +++ Define the playback rate options +++
options = { playbackRates: [0.5, 0.75, 1, 1.25, 1.5, 2] };

// +++ Turn off the default source order +++
if (Array.isArray(options.playbackRates)) {
  // Set sourceOrder to false - this means old browsers that support HLS in Flash but not HTML5/MSE will use MP4.
  // IE will use MP4/HTML5 before HLS/Flash
  myPlayer.options_.sourceOrder = false;

  // +++ Update the existing playback rate menu +++
  if (myPlayer.controlBar.playbackRateMenuButton) {
    var playbackControl = myPlayer.controlBar.playbackRateMenuButton;
    playbackControl.removeChild(playbackControl.menu);
    playbackControl.options_.playbackRates = options.playbackRates;
    playbackControl.addChild(playbackControl.createMenu());
    playbackControl.updateLabel();
    playbackControl.updateVisibility();
  } else {
    // +++ Add the playback rate menu +++
    myPlayer.controlBar.playbackRateMenuButton = myPlayer.controlBar.addChild(
      "PlaybackRateMenuButton",
      {
        playbackRates: options.playbackRates
      }
    );
    myPlayer.controlBar.playbackRateMenuButton.updateVisibility();
  }
}

// +++ Support for IE browsers +++
// This section is to keep the selected rate value from resetting to 1x when you pause and play in IE
if (videojs.browser.IE_VERSION) {
  console.log("IE_VERSION");
  //get method for selected playback rate value
  function getPlayBackRate() {
    rateEl = document.getElementsByClassName("vjs-playback-rate-value")[0];
    rateValue = rateEl.innerText.substr(0, rateEl.innerText.length - 1);
    return rateValue;
  }
  //get playback value when paused
  myPlayer.on("pause", function() {
    rateValue = getPlayBackRate();
  });
  myPlayer.on("ratechange", function() {
    //get new playback rate if the player is paused
    if (myPlayer.paused()) {
      rateValue = getPlayBackRate();
    }
  });
  //set backuped playback rate when playback starts
  myPlayer.on("play", function() {
    myPlayer.playbackRate(rateValue);
  });
}

以上是关于javascript brightcove.js的主要内容,如果未能解决你的问题,请参考以下文章

javascript的题。

javascript JavaScript isset()等效: - JavaScript

JavaScript 使用JavaScript更改CSS(JavaScript)

JavaScript之基础-1 JavaScript(概述基础语法)

前端基础-JavaScript的基本概述和语法

JavaScript