简体   繁体   中英

Javascript sounds in Android and Iphone browser

I'm developing simple javascript game, which should be embeded in Android and Iphone in-app browser. I have problem with sounds. I tried this, works good on PC, but not working on android and works strange with big delays on iphone.

init:

var hitSound = new Audio('hit.wav');

play:

hitSound.play();

How to play sounds without delay on Android and Iphone browser?

I think you're trying to use a HTML5 feature, which is not fully supported by Android's browser, at least up to FroYo. Still, if you use Android's WebView you can do the trick, but probably you are avoiding Native apps, aren't you?

This would help.

look for the page section where this is discussed:

The above two functions should be placed in the HEAD section between a

  <script language="JavaScript" type="text/javascript"> and a 

.

The best place and time to invoke the setEmbed function is in the BODY tag after page load:

  <body onload= "setEmbed('sample', 

'http://www.yourdomain.com/music/')">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM