Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Internet explorer audio.currentTime不';我不在IE9工作_Internet Explorer_Html_Audio_Internet Explorer 9_Html5 Audio - Fatal编程技术网

Internet explorer audio.currentTime不';我不在IE9工作

Internet explorer audio.currentTime不';我不在IE9工作,internet-explorer,html,audio,internet-explorer-9,html5-audio,Internet Explorer,Html,Audio,Internet Explorer 9,Html5 Audio,我真的不明白为什么除了IE9之外,以下代码似乎适用于所有浏览器: var audio = $("audio.laser").get(0); if (audio != null && audio.canPlayType) { audio.pause(); audio.currentTime = 0; audio.play(); } 奇怪的是,它冻结在“audio.currentTime=0”,表示“curre

我真的不明白为什么除了IE9之外,以下代码似乎适用于所有浏览器:

    var audio = $("audio.laser").get(0);
    if (audio != null && audio.canPlayType) {
        audio.pause();
        audio.currentTime = 0;
        audio.play();
    }

奇怪的是,它冻结在“audio.currentTime=0”,表示“currentTime未定义”。

不遵守标准是一种网络重罪,而IE9则是重犯。音频对我来说是只读的

仅支持以下内容:

要尝试的两件事是替换:

audio.currentTime=0

audio.currentTime=0.1

如果仍然出现相同的错误,您可以尝试将其替换为:

audio.load()


但是请注意,load()不能很好地处理“ended”事件。我想不出原因。

这段代码是在什么时候调用的?此时是否已触发loadedmetadata事件?能否发布调用此代码的脚本?感谢您指出loadedmetadata事件。我检查了一下,发现事件没有在IE中触发。我发现这是因为我使用的WAV格式不受支持。在播放声音之前,我添加了一个对音频持续时间的检查,比如:“audio.duration>=0”(引用Travis Powell发布的文章:“duration-获取当前媒体资源的持续时间(以秒为单位),如果持续时间不可用,则获取NaN值,如果媒体资源是流媒体,则获取无穷大。”。它有效。:)谢谢链接页面似乎确认currentTime存在。“获取或设置当前播放位置,以秒为单位。”感谢链接,我注意到出现了“W3CException_DOM_INVALID_STATE”异常,表示“未选择媒体源”。。。这怎么可能?HTML代码是:我清楚地选择它。。。