开发者

audio.currentTime doesn't work in IE9

I really don't see why the following code seems to work in every browser except IE9:

    var audio = $("audio.laser").get(0);
    if (audio != null && audio.canPlayType) {
        audio开发者_如何学JAVA.pause();
        audio.currentTime = 0;
        audio.play();
    }

Strangely, it freezes at "audio.currentTime = 0", saying "currentTime is undefined".


Failure to comply with standards is a web-felony, and IE9 is a repeat offender. Audio looks like it's read-only to me.

Only the things here are supported: http://msdn.microsoft.com/library/ff975061.aspx


A couple things to try would be to replace:

audio.currentTime = 0;

with

audio.currentTime = 0.1;

If that still gives you same error you could try replacing it with:

audio.load();

But be aware that load() does not play nicely with the "ended" event. The reason for this escapes me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜