2012-08-08 72 views
-1

我能夠播放獲取myTemplateLoaded上的警報並獲得第一個視頻的工作,但之後它不會推進到下一個視頻...請能有更多經驗的人幫腔??我會非常感謝!用於Brightcove視頻雲的Javascript

<!-- Start of Brightcove Player --> 
<div style="display:none"> </div> 
<script language="JavaScript" type="text/javascript" src="http://admin.brightcove.com/js/BrightcoveExperiences.js"></script> 
<object id="myExperience1116920512001" class="BrightcoveExperience" > 
<param name="bgcolor" value="#FFFFFF" /> 
<param name="width" value="480" /> 
<param name="height" value="270" /> 
<param name="playerID" value="1186083953001" /> 
<param name="playerKey" value="AQ~~,AAAAwFCyREk~,R6fcmQA_ySLOTNBFvZ0mjvLcTW-_NNbL" /> 
<param name="isVid" value="true" /> 
<param name="isUI" value="true" /> 
<param name="dynamicStreaming" value="true" /> 
<param name="@videoPlayer" value="ref:spring" /> 
<param name="includeAPI" value="true" /> 
<param name="templateLoadHandler" value="myTemplateLoaded" /> 
</object> 

<!-- End of Brightcove Player --> 

<script type="text/javascript"> 
var player; 
var modVP; 
var modExp; 
var modCon; 
var previousVideoID=0; 
var nextVideo=0; 
var videos=new Array(1772963843001,1765076426001,17490792490011); 
function myTemplateLoaded(experienceID) { 
// alert(experienceID); 
player = brightcove.api.getExperience(experienceID); 
modVP = player.getModule(brightcove.api.modules.APIModules.VIDEO_PLAYER); 
modExp = player.getModule(brightcove.api.modules.APIModules.EXPERIENCE); 
modCon = player.getModule(brightcove.api.modules.APIModules.CONTENT); 
modVP.loadVideoByID(videos[nextVideo]); 
modExp.addEventListener(brightcove.api.events.ExperienceEvent.TEMPLATE_READY, onTemplateReady); 
} 

function onTemplateReady(evt) { 
modVP.addEventListener(brightcove.api.events.MediaEvent.COMPLETE, onMediaComplete); 
modVP.addEventListener(brightcove.api.events.MediaEvent.CHANGE, onMediaChange); 
} 

function onMediaComplete() { 
nextVideo++; 
if (nextVideo==videos.length) { 
nextVideo=0; 
} 
modVP.loadVideoByID(videos[nextVideo]); 
} 

function getCurrentVideoCallback(currentVideo) { 
document.getElementById("currentVideoInfo").innerHTML = "Video named '" + currentVideo.displayName + "' loaded. Video ID: " + currentVideo.id; 
} 

function onMediaChange(evt) { 
document.getElementById("mediaInfo").innerHTML = "NOW PLAYING: " + evt.media.displayName; 
} 
</script> 
+0

我有一個新的更新上面的問題...代碼現在在jsfiddler工作,但不是在本地的瀏覽器...任何想法? (http://jsfiddle.net/ZHhKU/) – ristenk1 2012-08-08 18:35:50

回答

0

如果從文件系統本地運行,Brightcove API將不起作用。正如您在使用jsfiddle時所做的那樣,從Web服務器運行代碼。

0

您也可以在Mac上使用MAMP在本地測試您的頁面。只要確保將您的HTML文件保存到MAMP偏好設置的「Apache」選項卡中指定爲文檔根目錄的文件夾中即可。您還應該在「端口」標籤中「設置爲默認的Apache和MySQL端口」。

http://www.mamp.info/en/index.html