2014-05-16 78 views
1

我試圖抓住我的數據庫上最新的mp4文件 - 播放它 - 並在完成後重複該過程。但是,相同的文件一遍又一遍地循環。應該指出,我已經檢查了我的網絡服務&每次請求服務它確實給我新的文件按預期。video.js更新完成後的視頻

有沒有不同的方式來更新視頻播放器?如果可能,我寧願避免使用dispose方法並重新創建整個玩家。

videoURL = '/myService/get/' + sensorID + "?math=" + Math.random(); 

    _V_("video_player").ready(function() { 
     var myPlayer = this; 

     myPlayer.src({ 
      type : "video/mp4", 
      src : videoURL 
     }); 

     myPlayer.load(); 

     this.on("ended", function() { 
      myPlayer.src({ 
       type : "video/mp4", 
       src : videoURL 
     }); 
    }); 

回答

3

我假設隨機數是作爲緩存破壞者存在的。但是您的videoURL不會從一個迭代更改爲下一個迭代。您需要每次都生成一個新網址,例如

this.on("ended", function() { 
    videoURL = '/myService/get/' + sensorID + "?math=" + Math.random(); 
    myPlayer.src({ 
    type : "video/mp4", 
    src : videoURL 
    }); 
}); 
+0

盯着它我沒看見它。果然是這個問題。是的,這是一個緩存解決方案,因爲我喜歡這個想法 –