HTML5 Audio
- Started
- Last post
- 7 Responses
- stewdio
Safari does this beautifully. But I'm having a lot of issues with FireFox and Chrome. At first I thought this was due to my Ogg encoding, but now I have Chrome playing MP3s instead and the bug remains.
From what I can tell, the playhead on the audio file gets left in random spots after the file has been played. (Super weird right?) I tried to manually reset the "currentTime" attribute before each "play()" command but that doesn't seem to work either. Strange. And frustrating. Anyone else?
- stewdio0
Here's the working draft documentation:
http://www.whatwg.org/specs/web-…And here's an example of moving the playhead via jQuery:
$( "myAudio" ).trigger( "pause" );
$( "myAudio" ).attr( "currentTime", 0 );
$( "myAudio" ).trigger( "play" );
- stewdio0
Hmmm.... no responses. Too much of a tech question for QBN perhaps?
- version30
it's saturday
- uan0
I have no idea...unload, reload maybe?
- acescence0
well first of all you'll find that all of this stuff is buggy as fuck, since the spec is not nailed down yet. anyway, I would just use the Audio api...
var myAudio = new Audio("file.mp3");
myAudio.currentTime = 0;
myAudio.play();
- stewdio0
@acescence. It's not an API that's tripping me up. This seems to be an actual flaw in Chrome and FireFox. (I suppose it's understandable, the spec itself is still in flux.) The assignment "currentTime = 0" doesn't seem to reset the media's playhead. And FireFox doesn't even recognize the "startTime" property. Safari is truly the king here.