将视频ID传递给Brightcove HTML5播放器

时间:2016-11-16 15:22:34

标签: jquery brightcove

我尝试根据用户点击Brightcove HTML5播放器的链接动态传递数据视频ID。我试图使用jQuery,但无法找到在视频标记内的data-video-id标记内插入变量的正确方法。提前感谢您的任何帮助。

    JS:
            function sendVal(brightcoveId) {
                var myId = brightcoveId;
                $("#video_1").html('data-video-id=" + (myId) + "' );
            }
        </script>  

 HTML: 
<video 
        id="video_1"
        data-account="54541216001" 
        data-player="a53534534-7a60-5f3a-9152-989ccbbf6112" 
        data-embed="default" 
        class="video-js" 
        controls 
        style="width: 100%; height: 100%; position: absolute; top: 0px; bottom: 0px; right: 0px; left: 0px;"></video>

1 个答案:

答案 0 :(得分:0)

好的 - 找到Brightcove建议的解决方法:

// Initialise player
    var brightcovePlayer;
    // When the player's ready, let's get started
    videojs("video_1").ready(function(){
        brightcovePlayer = this;
    });
    function changeVideo(brightcoveId){
        brightcovePlayer.catalog.getVideo(brightcoveId, function(error, video) { 
            // Load the video
            brightcovePlayer.catalog.load(video);
            // Play the video
            brightcovePlayer.play();
        })
    }