Preloading music doesn't work in mobile?

Discussion and feedback on Construct 2

Post » Mon Mar 07, 2016 4:57 pm

@matrixreal - that code is pretty much what the Audio plugin is already doing.
Scirra Founder
B
403
S
238
G
89
Posts: 24,653
Reputation: 196,143

Post » Mon Mar 07, 2016 6:26 pm

@ashley so the only method using webview and to ensure smooth music playback is to load it all into sound and go from there? The only issue with that though is it causes the app to crash after roughly 1/3 of the music is loaded. I gather that it decompresses them as .wav files, as the actual .m4a files only take a total of 20mb after export.

Am I missing any steps to reduce the music footprint, or is there a method of offloading what has been preloaded to prevent crashes? Thank you!
B
37
S
5
G
1
Posts: 155
Reputation: 2,140

Post » Mon Mar 07, 2016 6:43 pm

Yeah, music is fully decompressed and it uses a lot of memory. We are also forced to do this in WKWebView (just blogged about it here). I guess we need to add a memory management solution for music playback with the Web Audio API. Maybe we could even make it an option on the Audio object so you can choose to opt in to treating music as sound so you get the preloading and seamless-looping benefits? It could easily use 50mb memory for a single track though.

I think the engine already restricts there to be only one music track playing at a time, so maybe if you only pay the memory overhead for the current track, it might be OK...
Scirra Founder
B
403
S
238
G
89
Posts: 24,653
Reputation: 196,143

Post » Mon Mar 07, 2016 6:54 pm

@ashley I've tried something similar. This was all done when they were in the sound folder, with preload sounds set to off.

At first I tried loading all the music tracks on boot up. That failed, caused a crash.

Then I tried splitting up the preloading between the first 3 layouts. That failed, caused a crash.

Then I tried only preloading music when it was needed. That worked...for about the first 1/4 tracks. After that you could tell it was starting to bog everything down by having it all loaded into the memory, and eventually yes, caused a crash.

It's worth mentioning that Blitz uses roughly 20 music tracks. 14 of them are rather long, and definitely the ones causing issues. That being said if I could load/unload them 1 at a time I could make it work as these are the tracks that load in game, as opposed to during the menus.

I've tried many many solutions, and will continue to experiment. I don't want to make your life harder, but as it stands it's hindering me releasing Blitz on iOS (probably android too, but one thing at a time). As it stands I may just attempt to optimize the living hell out of it to get it running smoothly on cocoon.io, as the canvas+ webview fully supports preloading the music via the music folder (and uses .ogg as well, for what it's worth), but man it's a tiny bit frustrating to be so close and yet so far. I hope you understand!
B
37
S
5
G
1
Posts: 155
Reputation: 2,140

Post » Sat Mar 12, 2016 10:19 pm

Hey @ashley, not to badger but I'm just wondering if you've given any thought into memory management solutions? I'm currently talking to a few publishers for mobile and would like to figure out if I should wait to get wkwebview working properly or if I should go all in on cocoon.io (which has worse performance but better audio atm).

So I want to see if you're considering adding it in a future update, as I would love to see that :D

Thanks!
B
37
S
5
G
1
Posts: 155
Reputation: 2,140

Post » Mon Mar 14, 2016 11:43 am

I will look in to memory management for music at some point, but I can't give any ETA right now. We're constantly extremely busy balancing Construct 3 development and Construct 2 maintenance.
Scirra Founder
B
403
S
238
G
89
Posts: 24,653
Reputation: 196,143

Post » Sat Mar 19, 2016 10:09 pm

Alright, thanks for the reply @ashley. Since there isn't an ETA, I'll try and figure out the performance issues on cocoon.io (it's almost good to go an iPhone 6, but it takes up A LOT of cpu), since I can get audio working properly on that.

I appreciate your time, cheers.
B
37
S
5
G
1
Posts: 155
Reputation: 2,140

Post » Fri Jul 21, 2017 9:38 pm

@blekdar Hey did you ever get pre loading sounds to work in Cocoon io - Canvas+
Image
B
29
S
8
G
1
Posts: 120
Reputation: 2,837

Post » Wed Aug 16, 2017 10:42 am

Hi, guys! I just wanted to mention that I had the same issue. Musics weren't playing on iOS and Android.
As previously said, I did following changes to my project and it works:
- Moved all music files from Music to Sound folder inside C2;
- Removed my previous events (that were using System variable comparisons), and started using "On Touch" and "On Keyboard key pressed" events to play musics;

It now works like a charm in iOS & Android (tested as native app on real device).
I exported project for Cordova, then built a zip via Intel XDK, and got the ipa & apk with PhoneGap.
Image
Version 1.1.2 - Available for: Web - iOS - Android
B
16
S
3
Posts: 50
Reputation: 1,046

Previous

Return to Construct 2 General

Who is online

Users browsing this forum: AppStar and 11 guests