views:

1722

answers:

8

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?

A: 

You can do it with an old-fashioned embed tag, but I have no idea if Mobile Safari will honor its loop attribute.

Azeem.Butt
Mobile Safari doesn't appear to honor the loop attribute.
Peeps
+2  A: 

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>
Cory Wiles
A: 

What about:

<audio src="noise.mp3" autoplay="" controls="" onended="this.play()"></audio>
Paul Rouget
+1  A: 

iPhone OS 3.0 doesn't support the <audio> tag completely - all it will do with it is play it in full in the QuickTime style.

misuba
A: 

Playing media like video or sounds are not allowed (so far). If you want to play video or audio, the iPhone will open it in an external (default) player. When the player is open, you do not have any control over the webpage untill the user shut-down the external player or the video/sound has stopped by itself.

Barry
A: 

Did anyone ever get this to work properly? I've tried the above sets of code and still have the problem of it going into the full screen mode.

cjdsie
I'm fairly sure that iPhone OS 4.0 will not play video/audio embedded in pages in a full-screen mode. OS 4.0 is due for release this summer.
Peeps
A: 

That's why apple sucks, have made a very nice music service with nice visuals such as vu-indications and equalizer, but.... not working on apple (mobile) stuff. Other devices works fine,

Quicktime sucks because it is the most incomplete software, you cannot hide it and make your own music webapp for the iPhone. Reason: iPod service, iTunes, iStore or iWhatEver. They claim that Flash is not open, what about the Apple OS? It is not about performance, battery consumption, They don't want you to use flash as is mean to be, you must use Flash as an extension not to build a website with it. On the iPhone, you can't play music with it without an Apple logo. Stupid. HTML 5 is still not the same as Flash, quicktime either. Quicktime sucks (or Apple, not open ;-))! I don't want to build an application especially for the iPhone, it must be open!

Erwinus
+3  A: 

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.

Shane McWhorter