Im using the following jquery to add HTML5 audio element to an otherwise basic HTML page. I want the audio tag to start playback automatically (the user will navigate to this specific page/area for the explicit purpose of hearing audio stream of a talk show).
It loads and playback starts fine on desktop web browsers and on test android devices, but in ios7 (test device is an iphone 4s), I can see the test alert triggered, but the play status for the audio element doesnt seem to be accessible / responsive at all.
Anyone familiar with a way to set autoplay successfully or to somehow 'trigger' the play status for the audio tag in ios7?
if not, I guess it DOES give me the chance to get the user (mobile device users exclusively) to confirm / acknowledge that they understand the bandwidth implications etc. etc. etc. and have their manual 'click' act as the trigger to start playback.
just thought I'd see if anyone here was familiar with a way to do this in ios7 -- Im not sure if it was also a problem under the previous version of iOS.
Thanks.
heres my code snippet:
$(document).ready(function() {
$('body').append('<audio src="EXTERNAL_AUDIO_STREAM_URL_HERE" autoload="false" autoplay="false" id="audiostream" controls/>');
// THIS WORKS FINE WHEN THIS ELEMENT IS CLICKED IN IOS7 MANUALLY, THE AUDIO STARTS FINE...
$('#startbutton').click(function(){
$('#audiostream')[0].load();
$('#audiostream')[0].play();
alert('loaded, fine...');
});
// THIS DOES NOT START AUDIO IN IOS7 AUTOMATICALLY...
setTimeout(function() {
$('#startbutton').trigger('click');
}, 2000);
});