Audio on app stops pulling tracks from list when screen turns off

Hello! :wave:t2:

I have been developing an app that plays calming music and also pulls random audio tracks from a database list to stream one after another. When this list is over, it repopulates and continues playing in a random order. :grinning:

The issue I’m having as I test the app, is that when my phone screen turns off after a few minutes, the background music loop continues unhindered, but these shuffled audio tracks stop after about 1 or 2 minutes. Usually they do not even start up again when I unlock my screen, unless I move away from that Media screen and come back, restarting that screen.

This is a problem, because the point of the app is to help people sleep… :sleeping: so the app really needs to continue playing, even if the phone screen turns off!

Many thanks for any assistance! :grinning:

2 Likes

If you run the app as a Web App it will continue working after the screen is turned off.

1 Like

Thank you for your help Muneer!

I apologise again if my beginner questions are silly, but I am a little confused. :upside_down_face:

I would like the app to run on the users phone, a downloadable app from the play store.
Can I still do this if I make it run as a web app? :thinking:
Is it easy to make it run as a web app? Do I need to change anything about the app, as it’s pretty much all ready to go at this point?

Many thanks!

2 Likes

Android 11 will allow normal apps to continue working in the background.
The web app is different and you can only add a shortcut to the device Home screen.

In theory, you should not need to change anything but running an app on the web is of course different that running it as a normal phone app. You might also face issues about adjusting the display to fit the web. Another point to look into that not every component is supported as a web app but that is only if you actually use such components.

This is a demo app for audio in the background. Try to see how if works
https://thunkable.site/w/7qw800Ecg

2 Likes

Hello @muneer … My phone just got updated to Android 11… Thunkable made app is a “normal” app, so will run now in background ? That will be a huge step forward for me :slight_smile:
Asking this because all crashing reports from Google PlayStore in my admin`s console are because users put app in background, and app crashes.

Later edit after testing… it seems that a thunkable made app is not a “normal” one… still crashes when put in background :blush:

2 Likes

Android 11 is supposed to supply the system resources to apps (certain criteria, I guess)even when in background. I just tested my Audio Sample project using Thunkable Live App on my son’s phone and the music continued while in background.

I did not test the APK. Just ran the project from the Thunkable Live App.

Hmm, my app doesn’t crash or turn off when the screen turns off and the background music keeps running locally. It is just that the audio files being pulled from the internet stop coming in.

I’m not sure if converting this to a web app will cause a whole new slew of issues to resolve :grimacing: , I don’t know how to make a web app or if I need to host this somewhere - it’s all brand new to me and time is running out for this project. As far as I can see, this is my only issue before launch.

Is there a SIMPLE solution to make the media screen stay switched on, if the user has not actively switched it off? (Like how youtube app will keep streaming a video if you put your phone down and do not interact for long periods of time?) I just want to resolve this issue asap - the media needs to keep playing for them, and I don’t want them to need to keep touching the screen to keep it engaged or change their phone settings if they have it automatically turn off after a few minutes.

Does that make sense? :thinking:

Open to any other suggestions!

Many thanks for your help! Can’t wait to get this one over the line after 2 YEARS! :dizzy: :star_struck: :dizzy:

2 Likes

This will help you ? Or you want the screen to turn off, to let user sleep according to that relaxing music ? :thinking:

3 Likes

Thank you!

To answer your question… ideally they could let the screen switch off and the app would continue working, but it sounds like that isn’t an option unless I change the app to a web app and do a bunch of other inevitable fixes. :weary:

So, I’m brainstorming - what will help this situation? What will be more helpful for the user? As it stands, my own phone turns off automatically after 2 or 3 mins of no use, which is way too fast for my app to stop working… so then I need to keep opening the app up, no way I could fall asleep in that time. So maybe if I stop the phone from automatically turning off, they will at least have the option to turn their phone over with the app still playing? Otherwise, they potentially get a very short time and then the app stops.

I’m open to any other suggestions and ideas on simple solutions to work around this scenario!

Is there some way to get the app to keep running the audio tracks when the screen is switched off besides converting to a web app and likely causing myself a lot more work? :upside_down_face:

3 Likes

I think this might be a good fix for now actually. It works great! Thank you for your help. :grinning: :star_struck: Of course, if there comes a simple solution to keep the app going when the screen turns off, by all means, please do share it on this thread. :grin:

2 Likes