Audio html5 tag does not play on iOS

1

I have a webpage that loads audio content with the <audio> tag Audio plays on Android and Windows without problem but in iOS 10.3.3 it can not be played

<audio controls="true"> <source src="http://192.168.1.25:8080/" preload="none"  type="audio/mpeg" autoplay></audio>

With any iOS browser (firefox, chrome, safari) it does not work. What is the problem? Thanks, best regards

    
asked by javier 16.12.2018 в 14:34
source

1 answer

3

iOS prevents automatic audio playback (ignores the autoplay attribute), which I suppose is the source of your problem. Nor can you trigger the playback before an event onLoad or similar, but before a onClick .

The logic of Apple is that, without an initiative on the part of the user, the reproduction should not begin, because that implies a download (of the data of the audio or video), that can carry costs in the data rate of the user. Therefore it must be the user who consciously starts the playback.

You should therefore add to the page some message of the style "If you are on iOS, to start playing the audio play here" and have an attribute onclick="document.miAudio.play()

    
answered by 16.12.2018 в 17:17