【问题标题】: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);

【讨论】:

    【解决方案2】:

    据我了解,在 iPad 上无法实现自动解决方案,因为用户必须点击海报或电影according to Apple's documentation

    【讨论】:

      【解决方案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

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2013-12-12
            • 2014-03-09
            • 2015-04-03
            • 2014-02-12
            • 1970-01-01
            • 2016-08-15
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多