Safari iOS HTML5 AAC WHY WHY WHY

Get help using Construct 2

Post » Tue Mar 13, 2012 4:45 am

I've written a project which uses sound effects, they are stored in the program as AAC and OGG. The sound files work in Chrome and Firefox, but fail to play when accessing my game from Safari on my iPad running iOS 5.1.

http://www.w3schools.com/html5/tryit.asp?filename=tryhtml5_audio_all
This plays from my ipad, so i'm assuming it is using AAC, as AAC is supported by Safari.

How come the audio plugin doesn't work? Actually the first time I tried it, it played some of the sound files, though it never played the music. After that, it never played the audio files again.

I read on a previous post that mentioned you might have to first preload the sound file, and then use the play sound call, is that true?

Many posts mention using Appmobi to export the app. Does this mean that it produces an iOS application, or is it still accessible from iOS built in web browser Safari? I'm concerned because I need my construct 2 project to remain on a server because it makes use of the Ajax plugin.cacotigon2012-03-13 04:46:39
B
30
S
6
G
8
Posts: 232
Reputation: 6,119

Post » Tue Mar 13, 2012 3:43 pm

You shouldn't have to preload anything just to hear audio.

Are you playing your game in the browser or via PhoneGap or appMobi? If you're just in the browser, it's very difficult to get audio to play at all on iOS: the browser blocks all HTML5 audio unless initiated by a user-input action. That's why pressing a button on the w3schools site plays the audio, but a collision event or something else won't play the sound. On top of that I think in the browser it can only play one sound at a time.

The PhoneGap and appMobi wrappers use a native audio engine instead of the browser, which overcomes these limitations. (We only very recently added audio support for PhoneGap, since it was complicated)

I think AJAX should still work from appMobi or PhoneGap... maybe give it a go?Ashley2012-03-13 15:44:37
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,564

Post » Wed Mar 14, 2012 7:02 am

I'm playing it in the browser, it actually looks pretty nice on my ipad, given that it's not running fullscreen, and I haven't made any special changes to accomodate for mobile platforms.

Hmm, I was afraid that appmobi wouldn't work because the ajax call goes out to grab a file that resides in the local dropbox directory. But I'll give appMobi a go tomorrow.

Regarding the sounds:
Interesting, that explains why the sounds are working on the buttons, but not anywhere else in the program.

Thanks for the assistance~~

B
30
S
6
G
8
Posts: 232
Reputation: 6,119

Post » Fri Mar 16, 2012 12:56 am

@Ashley
Well, I've tried out AppMobi a little bit.

Steps:
1. Created a AppMobi sample project
2. Exported as AppMobi experimental directly into the Appmobi project directory, looked okay in XDK viewer
3. Built as a distributed webapp
4. Copied into my dropbox folder for testing.

My results were.... mixed to say the least.
Sound seems to work a little better, and everything works with my ipad 1st gen as well as an ipod touch. Downside, is that it doesn't view in firefox properly, three question marks show up and nothing loads at all. Chrome loads the game but the Touch plugin with mouse control is oddly disabled.

F5 Preview works on both browsers perfectly, and so does exporting as standard html5 and testing on a local wamp webserver, so I'm not really sure what's going on.

Any ideas?
B
30
S
6
G
8
Posts: 232
Reputation: 6,119

Post » Fri Mar 16, 2012 1:25 am

You should export separately for appMobi. Don't try to run a game exported for appMobi in a browser, it will only work with appMobi, for the other browsers you should export a second time as a standard HTML5 web site.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,564

Post » Fri Mar 16, 2012 2:09 am

I guess that makes sense. I was just trying to make a single webapp that people could navigate to regardless of whether they're mobiles or laptops. Maybe I could do a single regular webpage that detects the platform using some javascript (navigator.platform) which redirects to the appropriate page based on that.

As has been mentioned before, even with AppMobi support, playing sounds only works after a user interaction. (too bad there isn't a way to simulate a fake user input event for this purpose though)

Seems like if I really want sound at this point on a mobile platform, I'm going to have to build a dedicated app for it, guess I'll have to pony up 100 bucks a year for ios development license. (sigh)

Thanks again for your help.
B
30
S
6
G
8
Posts: 232
Reputation: 6,119

Post » Wed Apr 18, 2012 1:05 am

I've been scouring the Construct boards looking for info on audio performance for iOS web-based apps and everything seems to be pointing to no / spotty audio in this case.

You can do audio in iOS web based apps no problem. The key is to use the Sound Sprite concept and compile all your sound effects into a single audio file.

With the first user interaction (usually "Tap to Start") load the audio and immediately pause it. Then use seekTo() to jump around to the sounds that you want to play within that file. You are still limited to one sound at a time but it works.Bwakathaboom2012-04-18 01:05:34
B
2
Posts: 2
Reputation: 254

Post » Wed Apr 18, 2012 1:28 am

@Bwakathaboom, in the latest beta release (r87) you should be able to export via PhoneGap and get good sound support, including multiple sounds at once.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,564

Post » Wed Apr 18, 2012 4:01 am

I saw that but I'm looking for mobile games that run on the web as opposed to a compiled app.
B
2
Posts: 2
Reputation: 254

Post » Wed Jun 13, 2012 11:00 am

[QUOTE=Ashley] You shouldn't have to preload anything just to hear audio.

Are you playing your game in the browser or via PhoneGap or appMobi? If you're just in the browser, it's very difficult to get audio to play at all on iOS: the browser blocks all HTML5 audio unless initiated by a user-input action. That's why pressing a button on the w3schools site plays the audio, but a collision event or something else won't play the sound. On top of that I think in the browser it can only play one sound at a time.
/QUOTE]

Hi,

I've recently just picked up Construct 2 and I've made some small projects to test out its features. It all seems good so far apart from the lack of audio when playing through Safari on the iPads (tested on iPad 1[5.0.1], iPad 2[5.0.1] & iPad 3 [5.1])

I initially started out with a backing music track and a simple sound effect. I've since removed the music track to see if it was able to play the sound effect by itself, but I've still had no luck.

The sound effect is told to play on a button On Clicked event, and the files are within the 'Sounds' folder (there is a .m4a, .ogg and .wav)

Does anyone have any ideas? Everything seems to work fine through Safari on the iMac. Cheers.
B
3
Posts: 9
Reputation: 318

Next

Return to How do I....?

Who is online

Users browsing this forum: Aserak2012, ManuelPerez and 19 guests