Android Question exoplayer stops working

apti

Member
I have an audio player app that is being worked on. I am using exoplayer to do the lifting. I have mp3 playing with it fine. no issues at all including while the screen is off. background service handles all the music and can play mp3 for hours without interruption. However I am using the same thing, exoplayer to play internet radio streams. It works. Great thing so I can do it all in one place. however when on an internet stream I get different results. The music stream stops every 3 minutes shortly after the screen turns off. If I bring the screen back up the music picks up and plays again but stops after 3 minutes.

I am using createurisource and all works. something is stopping the stream after the device does dark, unlike the mp3 it is not playing background.

Can somebody tell me what is doing this and how to stop it?
 

apti

Member
Are you acquiring a wake lock with PhoneWakeState?
I feel ashamed that I have to say I am not sure what a "Wake lock" is. so I am going to assume I am not. It just seems like the phone is stopping the feed of the stream when it goes dark, yet using the same exoplayer on mp3 no issue. I was thinking the issue is external somehow.

Please teach me what the wake lock is and if it is something I need to handle and how. Experienced programmer but new in b4x.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I feel ashamed that I have to say I am not sure what a "Wake lock" is
Not at all. Android ecosystem is wide and (over)complex.

PhoneWakeState from the Phone library allow you to prevent the screen from turning off, which is probably not what you are looking. It also allow you to prevent the CPU from sleeping when the screen turns off (partial lock). This is what you need to acquire. The most important example is: https://www.b4x.com/android/forum/threads/background-location-tracking.99873/#content
 
Upvote 0

apti

Member
Not at all. Android ecosystem is wide and (over)complex.

PhoneWakeState from the Phone library allow you to prevent the screen from turning off, which is probably not what you are looking. It also allow you to prevent the CPU from sleeping when the screen turns off (partial lock). This is what you need to acquire. The most important example is: https://www.b4x.com/android/forum/threads/background-location-tracking.99873/#content
sorry for delay. I finally went and looked at this but I already did. I had the partial lock done exactly as in the example but same problem persists. The stream seems to stop being read shortly after the screen goes dark. Is there something else I could be missing because it should work and compared to the example it still should work. yet it does not. Running android 13 if that helps.
 
Upvote 0

apti

Member
Check in the device options whether you have an option to whitelist your app and allow it to run in the background.
wow. went in and found that setting and poof it works right. I would have thought that playing mp3 in background meant it was working in background already but I guess android just doesn't work that way. Common sense was not part of google's hiring.
Thank you that worked but is there a way to manage this from the program?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
 
Upvote 0
Top