I'm trying to make a HTML5 webapp that simply plays a sound over and over and over again, on my iPhone. I don't know any Obj-C to do it natively.
What I have works fine, but the sound only plays once:
<!DOCTYPE html>
<html>
<head>
<title>noisemaker!</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="maximum-scale=1, minimum-scale=1, width=device-width, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
</head>
<body>
<audio src="noise.mp3" autoplay controls loop></audio>
</body>
</html>
Is there a way to either bypass the QuickTime audio screen and loop it in the webpage, or get the QuickTime audio screen to loop the sound?
This is done by using the loop attribute of the <audio> tag. It is used to restart the audio again and again after loading the web page. This can be used in situations where the audio has to be looped until it is specifically stopped, like in the case of background music on a web page.
Add an audio file to a cell in an Audio Recorder or Amp rowTap an empty cell, then tap Loops. The Loop Browser opens. In the Loop Browser, tap Audio Files. Select the audio file you want to add.
I found that the "loop" attribute does not seem to fully work in the latest implementation of the HTML5 audio element on the iPhone (iOS 4.0). I found this to be a workaround:
<audio src="noise.mp3" onended="this.play();" controls="controls" autobuffer></audio>
I found that you have to not put "loop" in the above, or the "onended" event seems not to trigger (i.e. "loop" is partially implemented).
Note that "autoplay" is intentionally disabled on the iPhone.
It also seems that the "volume" attribute is not fully implemented at this time as well.
Note that with iOS 4 audio is played without the full-screen QT player.
Have you tried using key/value pairs for the attributes. I know you SHOULD be able to just specify the attr, but just to play devil's advocate. Try:
<audio src="noise.mp3" autoplay="autoplay" controls="controls" loop="loop"></audio>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With