ExoPlayer stutters / stops after screen turns off or in background

So I am going to edit the manifest file in Android Studio or is there a easier quicker way?

APK Editor Studio

https://qwertycube.com/apk-editor-studio/

1 Like

You can use al2alive extension by ullis reboter ,
https://ullisroboterseite.de/android-AI2-KeepAlive-en.html

Service manifest by manifest generator by atom developer
com.atomdeveloper.ManifestCode.aix (6.0 KB)

And its perfectly works in kodular too ,
test aia : MusicPlayer.aia (4.5 MB)

3 Likes

Not for a live stream just looping to a static sound .mp3

Works on stream too
MusicPlayer.apk (5.9 MB)

1 Like

Yes, exactly.

1 Like

That is generated by myself
https://atomdeveloper.com/manifestgenerator.html

1 Like

Yes, sorry

And obviously this does not have to be declared in the Manifest, since it is true by default:

service android:enabled="true"

Hmm @bodymindpower did you try to run app in background if yes then pls tell me also. I can added code to manifest using atom Developer extension and how did you run the code to perform background services ???

This is about a Foreground service (and not a Background service) to prevent Doze mode (and thus the stuttering / stopping of the sound in idle (sleep) mode).

1 Like

Thanks its work. But if i press backpress it will close app and stop the music.

Yes, of course, because the app is closed then and as I said:

2 Likes

thank you for clearing that up, much appreciated and embraced :slight_smile:

This one work very well on new Android versions when Doze mode exist(API >= 23), except when call Start function block got error
Screenshot_20210124-112552
on my phone Blackberry ZTE Android 6.0.1 (API 23).

It’s look like the code do not check if some fonctions are supported…

I used another app to test if the phone support Doze mode and i discover it does not support it.
So it’s mean i can not based on API version to check if the phone support it.

Do someone know how to check if Doze mode supported?

And then how to avoid sleep on old devices who do not support Doze mode?
I Set “Keep WiFi on during sleep” to “Always” and disable Battery Optimisation manually, but the internet still sleep when playing audio with Exo player.
But this happen only if playing playlist with multiple short audio, when playing a long one this do not happen.

1 Like

A post was split to a new topic: Simple Doze Mode Extension to find out, if Doze Mode is supported

https://developer.android.com/reference/android/content/Context.html#startForegroundService(android.content.Intent)

1 Like

Btw, the presence of Doze does NOT automatically imply that WLAN etc. are throttled / switched off in the background (idle mode); it seems to be manufacturer-dependent in this respect (Samsung is apparently primarily affected).

1 Like

You can actually change the UI. :wink:

@bodymindpower Is there any method now to play music in background?