html5-audio

Proper onload for <audio>

半世苍凉 提交于 2019-12-01 21:18:49
问题 I've been looking around and I'm starting to worry that this isn't possible. Is there any way to make a standard <audio> tag with fallbacks... <audio> <source src='song.ogg' type='audio/ogg'></source> <source src='song.mp3' type='audio/mp3'></source> </audio> ...have an onload event. I've looked around and all I could find are some hacks that may or may not work (they don't for me on Chrome) and the canplaythrough event. The reason I want this is because I am making a presentation that has

How can I stop and resume a live audio stream in HTML5 instead of just pausing it?

社会主义新天地 提交于 2019-12-01 20:56:40
问题 A notable issue that's appearing as I'm building a simple audio streaming element in HTML5 is that the <audio> tag doesn't behave as one would expect in regards to playing and pausing a live audio stream. I'm using the most basic HTML5 code for streaming the audio, an <audio> tag with controls, the source of which is a live stream, which can be demonstrated here: http://jsfiddle.net/uzzz03ha/ Current outcome : When the stream is first played, it plays whatever is streaming as expected. When

HTML5 validation error: Element source not allowed as a child element of audio in this context

断了今生、忘了曾经 提交于 2019-12-01 20:35:27
This is a snippet of code from my assignment. I've checked the w3 samples http://www.w3schools.com/html/html5_audio.asp and it is formatted correctly. Am I just going crazy because of these errors or did I miss something? I believe it's that the HTML5 source element doesn't like how the type is written in but how else would I do it? Please let me know if you guys see anything I'm just missing. <li>.ogg(HTML5 <code>audio</code> tag) <ul> <li style="list-style-type:none;"> <audio controls> ` <source src="/audio1/horse.ogg" type="audio/ogg"> <!-- IE Support --> <source src="http://itwp.macomb.edu

Loading an Audio buffer and play it using the audio tag

随声附和 提交于 2019-12-01 20:27:08
I am trying to load an audio buffer from an URL, and then to play it. I got most of the code form this HTML5 Rocks Tutorial . var request = new XMLHttpRequest(); request.open('GET', $(this).attr('data-url'), true); request.responseType = 'arraybuffer'; request.onload = function() { console.log(request); context.decodeAudioData(request.response, function(buffer) { console.log(buffer); $('#play').click(function() { var source = context.createBufferSource(); source.connect(context.destination); source.noteOn(0); }).removeAttr('disabled'); }, function(err) { console.log(err); }); }; request.send()

How can I stop and resume a live audio stream in HTML5 instead of just pausing it?

孤街浪徒 提交于 2019-12-01 20:09:40
A notable issue that's appearing as I'm building a simple audio streaming element in HTML5 is that the <audio> tag doesn't behave as one would expect in regards to playing and pausing a live audio stream. I'm using the most basic HTML5 code for streaming the audio, an <audio> tag with controls, the source of which is a live stream, which can be demonstrated here: http://jsfiddle.net/uzzz03ha/ Current outcome : When the stream is first played, it plays whatever is streaming as expected. When it's paused and played again, however, the audio resumes exactly where it left off when the stream was

Using local file as <audio> src

白昼怎懂夜的黑 提交于 2019-12-01 20:00:37
问题 Is it possible to use an audio file from the user's hard drive as the src attribute for an HTML5 <audio> tag? Maybe through an <input type="file" /> ? This might not be particularly useful in production, but I'm still curious if it can be done. 回答1: I can think of two ways. Within your audio tag: src="file:///C:/.../file.mp3" or you could use a Blob using the file API. HTML: <input type="file"></input> JS: audio.src = URL.createObjectURL(document.getElementsByTagName('input')[0].files[0]); 来源

Proper onload for <audio>

萝らか妹 提交于 2019-12-01 19:34:49
I've been looking around and I'm starting to worry that this isn't possible. Is there any way to make a standard <audio> tag with fallbacks... <audio> <source src='song.ogg' type='audio/ogg'></source> <source src='song.mp3' type='audio/mp3'></source> </audio> ...have an onload event. I've looked around and all I could find are some hacks that may or may not work (they don't for me on Chrome) and the canplaythrough event. The reason I want this is because I am making a presentation that has lots of audio clips to play at certain points. I don't want the presentation to start until all of the

Setting playbackRate on audio element connected to web audio api

孤者浪人 提交于 2019-12-01 18:15:10
I've been experimenting with connecting an audio element to the web audio api using createMediaElementSource and got it to work but one thing I need to do is change the playback rate of the audio tag and I couldn't get that to work. If you try to run the code below, you'll see that it works until you uncomment the line where we set the playback rate. When this line is in the audio gets muted. I know I can set the playback rate on an AudioBufferSourceNode using source.playbackRate.value but this is not what I'd like to do, I need to set the playback rate on the audio element while it's

Future of JavaScript audio?

喜你入骨 提交于 2019-12-01 18:13:19
问题 I'm teaching kids how to add audio to their JavaScript games and webpages. I knew about the HTML5 Audio API and am just now learning about the issues around the various browsers (IE surprisingly doesn't support WAV at all, etc). However, apparently there's a new Web Audio standard I was unaware of. Chrome fully supports it. Mozilla states the following about Web Audio and Firefox: Firefox currently supports the incompatible, Mozilla-specific Audio Data API, but it is marked as "deprecated" in

How to loop sound in JavaScript?

社会主义新天地 提交于 2019-12-01 17:42:44
I tried below code to play a sound in JavaScript for certain times but with no success, the sound plays just once, what is the problem? for(var i = 0; i < errors; i++){ PlaySound3(); } Function: function PlaySound3() { var audioElement = document.getElementById('beep'); audioElement.setAttribute("preload", "auto"); audioElement.autobuffer = true; audioElement.load(); audioElement.play(); }; HTML code: <audio id="beep"> <source src="assets/sound/beep.wav" type="audio/wav" /> </audio> If you want to play the sound infinitely use the attribute loop in the tag audio : <audio id="beep" loop>