2013-06-13 111 views
0

我正在構建一個視頻數據庫,並使用Brightcove作爲我的視頻提供商。我的數據庫返回一個視頻ID的列表,並選擇,該視頻應加載到一個div並開始播放。Brightcove視頻庫

到目前爲止,我有這樣的:

http://bigreviewtv.byteserve.com.au/bcgal2.html

<HTML> 
<HEAD> 

<script src="/jquery/jquery-1.7.1.min.js"></script> 

<script type="text/javascript" src="http://admin.brightcove.com/js/BrightcoveExperiences_all.js"></script> 
<script> 
newVideo = function(videoId) { 
     var newhtml = [ 
     '<object id="myExperience', videoId, '" class="BrightcoveExperience">' 
     , '<param name="bgcolor"   value="#FFFFFF" />' 
     , '<param name="width"   value="480" />' 
     , '<param name="height"   value="270" />' 
     , '<param name="playerKey"  value="AQ~~,AAACP3r8R8k~,kFpRRbL5Evyu4ko-Z7yiuqqeHKzo4hSs" />' 
     , '<param name="playerID"   value="2472217790001" />' 
     , '<param name="isVid"   value="true" />' 
     , '<param name="isUI"    value="true" />'  
     , '<param name="@videoPlayer"  value="' + videoId + '" />' 
     , '<param name="dynamicStreaming" value="true" />'  
    , '</object>' 
    ]; 
    //return $(newhtml.join('')).appendTo('#hero'); 
    //$("#hero").html(newhtml.join('')); 
    //alert(newhtml.join('')); 

    brightcove.createExperiences(); 
    }; 



</script> 

</HEAD> 
<BODY> 

<div id="hero" style="border:1px red dotted"> 

<object id="myExperience2472866007001" class="BrightcoveExperience"> 
    <param name="bgcolor" value="#FFFFFF" /> 
    <param name="width" value="480" /> 
    <param name="height" value="270" /> 
    <param name="playerID" value="2472217790001" /> 
    <param name="playerKey" value="AQ~~,AAACP3r8R8k~,kFpRRbL5Evyu4ko-Z7yiuqqeHKzo4hSs" /> 
    <param name="isVid" value="true" /> 
    <param name="isUI" value="true" /> 
    <param name="dynamicStreaming" value="true" /> 
    <param name="@videoPlayer" value="2472866007001" /> 
</object> 

</div> 



<div id="video-gallery"> 
    <div id="video-full"></div> 
    <ul id="video-thumbs"> 
<li><a href="javascript:newVideo('2472862365001')">Video 1</a></li> 
    <li><a href="javascript:newVideo(2472940937001)">Video 2</a></li> 
    <li><a href="javascript:newVideo(2472916922001)">Video 3</a></li> 
    </ul> 
</div><!-- /#video-gallery --> 


</BODY> 
</HTML> 


<script type="text/javascript">brightcove.createExperiences();</script> 

不幸的是預期它不工作。任何幫助,將不勝感激。

回答

0

你最好使用loadVideoByID()方法Brightcove的API中 - http://docs.brightcove.com/en/video-cloud/smart-player-api/reference/symbols/brightcove.api.modules.VideoPlayerModule.html#loadVideoByID

下面是一個例子:

<object id="myExperience921449663001" class="BrightcoveExperience"> 
    <param name="bgcolor" value="#FFFFFF" /> 
    <param name="width" value="480" /> 
    <param name="height" value="270" /> 
    <param name="playerID" value="2079935931001" /> 
    <param name="playerKey" value="AQ~~,AAAA1oy1bvE~,ALl2ezBj3WE0z3yX6Xw29sdCvkH5GCJv" /> 
    <param name="isVid" value="true" /> 
    <param name="isUI" value="true" /> 
    <param name="dynamicStreaming" value="true" /> 
    <param name="@videoPlayer" value="921449663001" /> 

    <param name="includeAPI" value="true" /> 
    <param name="templateLoadHandler" value="onTemplateLoad" /> 
    <param name="templateReadyHandler" value="onTemplateReady" /> 
</object> 
<script type="text/javascript"> 
brightcove.createExperiences(); 

function onTemplateLoad(experienceID) { 
    player = brightcove.api.getExperience(experienceID); 
    APIModules = brightcove.api.modules.APIModules; 
} 

function onTemplateReady(evt) { 
    videoPlayer = player.getModule(APIModules.VIDEO_PLAYER); 
} 
</script> 
<ul> 
    <li><a href="javascript:videoPlayer.loadVideoByID(928199562001)">928199562001</a></li> 
    <li><a href="javascript:videoPlayer.loadVideoByID(1325817301001)">1325817301001</a></li> 
    <li><a href="javascript:videoPlayer.loadVideoByID(1187545001001)">1187545001001</a></li> 
</ul> 

您將需要改變playerID,playerKey,@ videoPlayer和videoID以適應您的環境。

有跡象表明,通過如何做到這一點的http://docs.brightcove.com/en/video-cloud/smart-player-api/samples/fetch-playlists.htmlhttp://support.brightcove.com/en/video-cloud/docs/dynamically-loading-videos-using-smart-player-api

+0

對不起行走,閱讀在iPhone上,錯過了上面的例子中的文章和示例代碼。謝謝。不勝感激。 – AusS2000

+0

http://bigreviewtv.byteserve.com.au/bcgal4.html 找不到var:videoPlayer – AusS2000

+0

啊,從頭開始。我試圖在JS庫完全加載之前訪問它。有時間做一些教程。 – AusS2000