2013-02-28 53 views
3

無論是從控制檯還是從我的標記中,我都無法使用javascript設置html5視頻元素的當前時間。我也在使用jQuery,但我不知道這是否與問題相關。我在Ubuntu上使用Google Chrome 24.0.1312.57;下面是什麼,我試圖做無法在html5視頻中使用jquery/javascript設置video.currentTime

<html> 
<script type="text/javascript"> 
    var video = document.getElementById("video"); 
    var videoSourceString = "<source src=http://URL:PORT" + path + " type='video/mp4'></source>"; 
    $(video).html(videoSourceString); 
    video.load(); 
    var frameRate = 24; 
    video.currentTime += 1/frameRate;// doesn't do anything, leaves currentTime same as before 
</script> 
<body> 
<video id="video"> 
</video> 
</body> 
</html> 

視頻播放的例子,並暫停罰款,但每當我試圖手動更改時它不工作。

我已經看過HTML5 Video - Chrome - Error settings currentTime,控制檯中沒有這樣的錯誤,實際上它不顯示任何錯誤。我也無法使用video.currentTime + = 1或document.getElementById(「video」)。currentTime = 0使用任何數字從控制檯更改當前時間。

非常感謝!

+0

我會等到canplay(或loadedmetadata或durationchanged)事件在設置currentTime之前觸發 – Offbeatmammal 2013-02-28 01:23:00

回答

4

儘管我一直在等到loadedmetadata事件發生,但事實證明web.py對HTTP字節範圍請求的支持不足以阻止尋找。需要HTTP字節範圍請求才能在HTML5視頻中查找,並且事實證明web.py不支持它們,所以我使用Apache爲視頻提供服務,並且它的工作無懈可擊。謝謝您的反饋!