首页 > 解决方案 > 通过 id 将新视频加载到通过 Brightcove Player Loader 加载的 Brightcove 播放器中

问题描述

我已经使用 Brightcove Player Loader 在我的页面上加载了 Brightcove 视频播放器:

brightcovePlayerLoader({
    refNode: document.querySelector('#mainvid'),
     accountId: myaccountId, //this is a variable with global scope
    playerId: '947WeZ6d',
        videoId: mainvidID
     })
    .then(function(success) {
        myPlayer = success.ref;
        console.log('success', success);
        myPlayer.on('loadedmetadata',function(){
            //myPlayer.muted(true);
            //myPlayer.play();
         });
    })
    .catch(function(error) {
        console.log('error', error);
}); 

当用户单击图像时,我想读取图像的 ID 并将其用作 myPlayer 的新 VideoID。但我该怎么做呢?

$('.vid-thumbnail').on('click', function() {
    myPlayer.videoId = maidvidID; //doesn't work
});

标签: brightcove

解决方案


使用常规的播放器目录方法和返回的播放器success

myPlayer.catalog.getVideo('12345', function(error, video){
  myPlayer.catalog.load(video);
});

推荐阅读