<...">

Audio does not play on iPad

<audio id="test" controls="controls"> <source src="1.mp3" type="audio/mpeg" /> <source src="1.ogg" type="audio/ogg" /> </audio> 

js code for playing videos as downloads

 document.getElementById('test').load(); document.getElementById('test').play(); 

Works in browsers but not on iPad, what do I need to install?

+6
source share
1 answer

According to Apple's documentation, downloading and playing back audio / video content should be triggered from a user action:

In Safari on iOS (for all devices, including the iPad), where the user can be on the cellular network and charge per unit of data, preload and auto play are disabled. No data is downloaded until the user initiates it. This means that the JavaScript play () and load () methods are also inactive until the user starts to play, unless the play () or load () method is triggered by the user action. In other words, a user-initiated game button works, but the onLoad = "play ()" event does not work.

This plays the movie: <input type="button" value="Play" onClick="document.myMovie.play()">

It does nothing on iOS: <body onLoad="document.myMovie.play()">

Taken from here: http://developer.apple.com/library/safari/#documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html

+8
source

Source: https://habr.com/ru/post/901009/


All Articles