【问题标题】:HTML5 Video - Chrome - Error settings currentTimeHTML5 视频 - Chrome - 错误设置 currentTime
【发布时间】:2011-03-11 01:49:32
【问题描述】:
当我尝试在 Chrome 5.0.375.86 中设置 HTML5 Video 元素的 currentTime 时:
video.currentTime = 1.0;
我收到以下 javascript 异常:
Uncaught Error: INDEX_SIZE_ERR: DOM Exception 1
它在 Safari 中运行良好。有人经历过吗?
【问题讨论】:
标签:
javascript
html
google-chrome
html5-video
【解决方案1】:
试试这样的(JS):
function loadStart(event)
{
video.currentTime = 1.0;
}
function init()
{
video.addEventListener('loadedmetadata', loadStart, false);
}
document.addEventListener("DOMContentLoaded", init, false);
【解决方案3】:
这对我有用
video = document.getElementById('video');
begin_play = 50;
play_video_frist = true; //if you want to run only frist time
video.addEventListener("play", capture, false);
function capture(event)
{
if (event.type == "play"){
if(play_video_frist){
play_video_frist = false;
video.currentTime = begin_play;
}
}
}
【解决方案4】:
问题(至少关于 Chrome)可能出在服务器端。
将Header set Accept-Ranges bytes 放入您的.htaccess(此this answer)
【解决方案5】:
$video.on 'loadedmetadata', ->
$video[0].currentTime = parseInt(options.history)
使用咖啡脚本和 jQuery