【问题标题】:Brightcove Video Manager API, Get Playlist by ID java scriptBrightcove Video Manager API,通过 ID 获取播放列表 javascript
【发布时间】:2013-02-04 17:26:21
【问题描述】:

我对 java 脚本的整个想法还很陌生,我真的很想找到解决问题的方法。我已经放弃了 brightcove 用于视频管理器的模板,该视频管理器使用“获取所有播放列表 URL”调用。我试图只制作一个仅包含几个特定播放列表的菜单,并且在这样做时会出现一个又一个错误,无论我改变什么。截至目前,我的主要错误是“未捕获的类型错误:无法读取未定义的属性'长度'”。任何帮助将不胜感激。谢谢你。

//Get PlayList by ID

function getPlaylistLindyURL(){

loadStart();
paging.playlistbyid = (paging.currentFunction == getPlaylistLindyURL)?paging.generic:paging.playlistbyid;
paging.currentFunction = getPlaylistLindyURL;
return apiLocation +
'?command=find_playlist_by_id&playlist_id=1990786315001&callback=showPlaylistByIDCallBack'
    + '&get_item_count=true&page_size=' + paging.size + '&page_number='+paging.playlistbyid
    +'&token='+readToken;         



//Playlist by ID callback

function showPlaylistByIDCallBack(o){

if(null == o.error){
    oCurrentMainVideoList = o.items;
    buildMAinVideoList();
    doPageList(o.total_count, "Videos");
}else{
    var message = (null!=o.error.message)?o.error.message:o.error;
    alert("Server Error: "+ message);
}
loadEnd();
}


//For PlayList by ID

function buildMAinVideoList() {

//Wipe out the old results
$("#tbData").empty();

// Display video count
document.getElementById('divVideoCount').innerHTML = oCurrentMainVideoList.length + "Video";
document.getElementById('nameCol').innerHTML = "Video Name";
document.getElementById('headTitle').innerHTML = "All Videos";
document.getElementById('search').value = "Search Videos";
document.getElementById('tdMeta').style.display = "none";
document.getElementById('searchDiv').style.display = "none";
document.getElementById('checkToggle').style.display = "none";
$("span[name=buttonRow]").hide();
$(":button[name=delFromPlstButton]").hide();


//For each retrieved video, add a row to the table
var modDate = new Date();
$.each(oCurrentMainVideoList, function(i,n){
    modDate.setTime(n.lastModifiedDate);
    $("#tbData").append(
        "<tr style=\"cursor:pointer;\" id=\""+(i)+"\"> \
        <td>\
            <input type=\"checkbox\" value=\""+(i)+"\" id=\""+(i)+"\" onclick=\"checkCheck()\">\
        </td><td>"
            +n.name +
        "</td><td>"
            +(modDate.getMonth()+1)+"/"+modDate.getDate()+"/"+modDate.getFullYear()+"\
        </td><td>"
            +n.id+
        "</td><td>"
            +((n.referenceId)?n.referenceId:'')+
        "</td></tr>"
    ).children("tr").bind('click', function(){
        showMetaData(this.id);
    })
});

【问题讨论】:

    标签: javascript api typeerror brightcove


    【解决方案1】:

    从您发布的代码看来,oCurrentMainVideoList 似乎没有在任何地方声明,所以这可能就是它说它未定义的原因......

    如果你把它定义为一个全局变量,从它的外观来看,它必须是一个全局变量,确保你已经为它设置了一个值。但是你不应该使用全局变量,为你的函数创建一个命名空间,它有助于范围控制。

    如果您想了解一些 JS 最佳实践,您应该观看来自 TekPub 的视频: JS_UpToSpeed

    在发布之前,您还应该花时间查看代码并使其更具可读性,缺少缩进使代码难以阅读,并且 buildMAinVideoList 中有多个大写字母。

    【讨论】:

      猜你喜欢
      • 2021-02-11
      • 1970-01-01
      • 2023-04-03
      • 2015-10-26
      • 2012-08-06
      • 1970-01-01
      • 2011-09-23
      • 2016-09-07
      • 2011-10-27
      相关资源
      最近更新 更多