Music player for Android

Started by cat, Wed 25/05/2022 08:20:08

Previous topic - Next topic

cat

Hi!

I hope this is the right place to post this.

Background: My kids have this Hörbert audio player (https://www.hoerbert.com/wp-content/uploads/sites/5/2017/07/hoerbert-standart-2-e1505730962378.jpg) which basically is a wooden box with a speaker and buttons. Inside is an SD card where you can copy audio files in a certain file structure which results in a playlist for each of the buttons. Since the device is quite heavy, I thought it would be nice to have this on my phone instead for travelling.
I'm using the latest stable AGS (3.5.1. I think it is?) and the Android player on my phone (no idea which version, I can't figure that out). I could update to 3.6.0 if this helps.
I got the basic handling (with lots of swearing about AGS's limited array functionality) but a few questions arise.

1) When I turn off the screen of my phone to save battery, the music stops as well. Is it possible to have this continue running?

2) I included all audio files in the game which makes quite a big vox file and is somewhat impractical because I have to recompile the whole game to change the playlists. Is it possible to a) access audio files from the file system and b) play such files in AGS?

3) When you hold down the back button, a menu will appear. Is it possible to disable this menu? My kids will certainly open this by accident and then cause mayhem on my phone.

Crimson Wizard

#1
Quote from: cat on Wed 25/05/2022 08:20:08
2) I included all audio files in the game which makes quite a big vox file and is somewhat impractical because I have to recompile the whole game to change the playlists. Is it possible to a) access audio files from the file system and b) play such files in AGS?

There's a deprecated PlayMP3File function that may be turned on by disabling "Enforcing new-style audio scripting". The problem with it will be that it returns a result rather than audio channel pointer, but if you have reserved limited number of music channels, then you may deduce its index and access as System.AudioChannels[n].

Also, AGS naturally supports loading any game resources from the filesystem, if they are present there. It's bit complicated with new audio clips system, because the files have to be called how they are called in AudioCache, using generated names instead of original names. That will also only work if you want to provide replacement for registered resources, otherwise there will be no way to run these.

Quote from: cat on Wed 25/05/2022 08:20:08
3) When you hold down the back button, a menu will appear. Is it possible to disable this menu? My kids will certainly open this by accident and then cause mayhem on my phone.

No, but if you build for Android in 3.6.0 Editor, it will create an individual APK which does not have this menu. Thinking about it, I don't know if reading files from the file system will work with that form of compiled game; but maybe worth checking out.

Alternatively, this may be a feature request for the universal game player in 3.6.0, perhaps it could have a config setting for disabling this menu.

Quote from: cat on Wed 25/05/2022 08:20:08
1) When I turn off the screen of my phone to save battery, the music stops as well. Is it possible to have this continue running?

I'd first try enabling multitasking mode in the game (SetMultitaskingMode), e.g. on desktop systems that keeps game running when they are switched out from. But if that won't work, that's a question of how port works in general.

Cassiebsg

An idea on how 2) might work:

Generate a txt file with the name of your music files, one per line. Then read from AGS the file and grab the name of each file, and pass it as the filename to read and play the correct file (using the PlayMP3File as suggested by CW).

Of course you'll need to generate this file every time you add a new song to the folder, but it should work (in theory anyway).  (nod)
There are those who believe that life here began out there...

cat

#3
Ok, I will skip loading the files from storage now. And I'll finally have a look at building a native apk...
I created an Excel sheet for generating the code for setting up the playlists, so it is not that much work (i.e. list7[0] = a7_0;)

SetMultitaskingMode did not work. Even the documentation say nothing about Android:

Quote
Cross-Platform Support

Windows: Yes
Linux: Yes
MacOS: Yes



eri0o

I don't think currently SDL2 Android supports keeping the screen off and still keep things executing. I need to research more on the subject before saying more.

Khris

I'm pretty sure you need to write a so-called service for that (i.e. the optional part of an app that runs in the background and keeps running when you leave the app, which is what happens when you turn off the screen).

Learning how to write a simple Music player app that reads folders from the SD card probably takes less time than getting it to work with AGS (if that's even possible).

cat

Quote from: Khris on Thu 26/05/2022 00:21:11
Learning how to write a simple Music player app that reads folders from the SD card probably takes less time than getting it to work with AGS (if that's even possible).
You are right, I should finally start getting into writing Android apps. Time to learn something new!

But anyway, except for a few minor issues I managed to get my music player working. Even if there are better tools to achieve my goal, I think it is pretty amazing what you can do with a software that was built for making adventure games  ;-D

Thanks for the answers!

SMF spam blocked by CleanTalk