Mozilla Firefox出错。

时间:2014-03-01 19:49:16

标签: javascript jquery html html5 firefox

我为HTML5视频播放器编写HTML / JS代码并在Firefox 27.0.1版本中出错,在Ubuntu / Windows Chrome中有效,在IE11中它可以正常工作。

HTML

<div id="newprogressBar" style="border:1px solid #aaa; color:#fff; width:295px; height:20px;"><span id="newprogress" style="background-color:#ff0000; height:20px; display:inline-block;"></span></div>

HTML in HTML

var video = document.getElementById("videoPlayer"), (HTML5 <video *.mp4>)
newprogressBar = document.getElementById("newprogressBar");
newprogress = document.getElementById("newprogress");

JS中的事件函数

newprogressBar.addEventListener('click', function(event) {
width = parseFloat(newprogressBar.style.width);
var x = event.offsetX / width;  
video.currentTime = Math.round(x * video.duration);
}, false);  

我在Firefox中的这一行有错误

video.currentTime = Math.round(x * video.duration);

错误:

TypeError: Value being assigned to HTMLMediaElement.currentTime is not a finite floating-point value.

1 个答案:

答案 0 :(得分:1)

检查视频标记内的.webm视频文件。 Linux上的Firefox(也可能在其他操作系统上)不能播放.mp4文件。