Preloading music doesn't work in mobile?

Discussion and feedback on Construct 2

Post » Sat Mar 05, 2016 3:31 pm

Hey everyone,

I've been prepping Blitz Breaker for mobile release, and have been running into some major issues with audio.

One of the game's biggest selling points is how awesome the music is, so ensuring it plays smoothly is pretty pinnacle. The issues I'm running into kind of muck up that smoothness.

- First off, does preloading music not work on mobile? I've been using it on nw.js and it works just fine, but when I load the game up onto iOS or test it through mobile safari, I can't help but notice delays in the music loading. Also if I use the combination of 'Preload audio' action and the 'All preloads complete' condition, it just hangs on mobile, while working correctly through nw.js

- When playing music via the steaming method, there is a brutal noticeable delay when it loops. Is there anyway around this?

- I can work around the whole 'needs a touch event to start playing' but the delays are agonizing, especially when it loops.

- If all else fails, are there methods of reducing the footprint putting the music in the sound folder would take? I've tried reducing the quality but it didn't make any difference, and still crashes upon preloading it all through sounds.

If I am missing anything or if anyone has any tips please let me know. Thanks!
B
37
S
5
G
1
Posts: 155
Reputation: 2,140

Post » Sat Mar 05, 2016 4:31 pm

I thought preloading was only for html5 games, where it needs to download the music, sound, etc.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 961
Reputation: 10,717

Post » Sat Mar 05, 2016 9:25 pm

@and4d It can be used for nw.js, I know that for sure. It's what I've been doing for my game's music and it works flawlessly on PC. You can use it for sounds too if you have 'preload sounds' set to off in the editor. The issue I'm running into though is that if I do that on mobile, it uses up too much RAM and causes the app to crash.
B
37
S
5
G
1
Posts: 155
Reputation: 2,140

Post » Sun Mar 06, 2016 10:56 am

Preload does not work for iOS for awhile now, ever since iOS9, Apple broke that feature.

I don't know if @Ashley is aware of it or not, but there's been lots of audio related bugs with iOS9+.

Sometimes my audio tracks don't play at all, it's messed up actually!
B
70
S
24
G
19
Posts: 1,757
Reputation: 17,614

Post » Sun Mar 06, 2016 6:58 pm

@silverforce I just uploaded a sort of sound test app using cocoon.io's canvas plus, using all of blitz breaker's music files. It looks like it uses .ogg files instead of .m4a.

Anyways the files preloaded up perfectly and played without requiring a touch event and without a gap. Going to explore this and see how the game's performance is in general.
B
37
S
5
G
1
Posts: 155
Reputation: 2,140

Post » Sun Mar 06, 2016 10:14 pm

Canvas+ is their own engine so it does not have issues like Safari based ones that WebView has.

But WebView+ is heaps faster and more power efficient than Canvas+.
B
70
S
24
G
19
Posts: 1,757
Reputation: 17,614

Post » Mon Mar 07, 2016 7:08 am

Yes I couldn't help but noticing this after uploading the full game.

Back to the experimenting page, gonna play around and see what results I get with wkwebview, as that's where the performance is at.

May post a bug report here too, to help get ashley's attention.
B
37
S
5
G
1
Posts: 155
Reputation: 2,140

Post » Mon Mar 07, 2016 11:53 am

Mobile browsers have never supported preload for audio/video, ostensibly to save bandwidth on cellular data connections (but they still do this on wifi etc anyway). This exacerbates the fact you can only start playback in a touch, since it will have to start loading the track from scratch in the touch. Most browsers don't support seamless audio playback either. The workaround to all of this is to treat it as sound, but then playback won't begin until it's fully decoded and decompressed the track in memory.

These are the only options available in mobile browsers I'm afraid. I've argued a lot against the browser restrictions for music (played with the <audio> tag) pointing out you can work around every restriction, albeit inefficiently, with the Web Audio API, but they've never changed it...
Scirra Founder
B
387
S
230
G
87
Posts: 24,249
Reputation: 192,240

Post » Mon Mar 07, 2016 1:53 pm

Ashley wrote:Mobile browsers have never supported preload for audio/video, ostensibly to save bandwidth on cellular data connections (but they still do this on wifi etc anyway). This exacerbates the fact you can only start playback in a touch, since it will have to start loading the track from scratch in the touch. Most browsers don't support seamless audio playback either. The workaround to all of this is to treat it as sound, but then playback won't begin until it's fully decoded and decompressed the track in memory.

These are the only options available in mobile browsers I'm afraid. I've argued a lot against the browser restrictions for music (played with the <audio> tag) pointing out you can work around every restriction, albeit inefficiently, with the Web Audio API, but they've never changed it...


are you sure ?

cause i did done the preload on mobile (ejecta/cordova cli) on both android and ios by executing the javascript call (browser plugin) using these scripts (for example music.m4a)

to preload
var music1 = new Audio();
music1.preload = 'auto';
music1.src = 'media/music.m4a';

to play
music1.play();
B
45
S
16
G
8
Posts: 792
Reputation: 8,306

Post » Mon Mar 07, 2016 4:15 pm

@ashley Yes I'm aware that is the current work around. Unfortunately for me that won't work since the amount of music Blitz has causes the game to crash when it loads roughly half of the tracks, so it's not a viable work around. This will happen regardless whether or not I load them at the start of the game or try to stagger it with loading them throughout the game, since there is no method of unloading the tracks that aren't being used.

I do find it interesting that cocooon.io's canvasplus is able to preload music and play it reliably. I gather that it doesn't rely on apple's webview so it's able to get around some of it's limitations. The unfortunate part is that canvasplus' performance doesn't match wkwebview's, which has been stellar performance from a mobile stand point. I realize I could fix this with some heavy optimizing, but it's super frustrating that one option has the performance, while the other has correctly working music.

@matrixreal This is interesting, is there a method to detect if a music file has been successfully preloaded?
B
37
S
5
G
1
Posts: 155
Reputation: 2,140

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 12 guests