js多個視頻順序循環播放

window.οnlοad=function(){
    var str = '${vedioStr}'; //所要播放視頻的路徑組
    var strList = str.split("X");//要循序播放的路徑組字符串轉換成路徑數組
    var i=0;
    var len = strList.length;
    if( strList[i] != null && strList[i]!='' && strList[i] !='null'){
        $("#XX").find("OBJECT").attr("filename", strList[i]);//設置視頻路徑爲第一個路徑組路徑
    }
    window.setInterval(function(){ //每過0.5秒監控一下視頻是否正在播放,如果沒在播放則順序播放下一個視頻
        if($("#XX").find("OBJECT").attr("playState")==0){ //判斷視頻的播放狀態不同player狀態不同
            i++; //處理播放順序和for循環處理差不錯
            if(i==len){
                i=0;
            }
            if( strList[i] != null && strList[i]!='' && strList[i] !='null'){
                $("#XX").find("OBJECT").attr("filename", strList[i]);    //如果當前播放完畢則播放下一個
            }
        }
    }
}, 500);    //每個0.5秒監控 一下

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章