javascript 触发Brightcove视频

Posted

tags:

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

(function(GW, $) {
  'use strict';

  const videoContainer = document.querySelector('.js-video-container');
  const theURL = 'https://players.brightcove.net';
  // Get a reference to the iframe element
  const iframeTag = videoContainer.querySelector('iframe');
  // Retrieve window object needed for postMessage
  const window = iframeTag.contentWindow;

  /**
   * Play Brightcove videos.
   * @param {Event} event - Prevents the default event of the trigger.
   */
  GW.playVideos = function(event) {
    event.preventDefault();
    videoContainer.classList.add('full-width-video__video-container--active');
    window.postMessage('playVideo', theURL);
  };

  GW.fullWidthVideo = {
    init: function() {
      const videoTrigger = document.querySelector('.js-video-play');
      videoTrigger.addEventListener('click', GW.playVideos);
    }
  };
}(window.GW = window.GW || {}, jQuery));

以上是关于javascript 触发Brightcove视频的主要内容,如果未能解决你的问题,请参考以下文章