Exoplayer about 10 or 15 minutes the application closes when the screen turns off

I was using Taifun Player, but I read that it gave problems on some Chinese smartphones and some locks appeared on the play console. Then I read through the forum that exoplayer also allows looping and I tried it. But while TaifunPlayer does not close the application even if the screen turns off, exoplayer about 10 or 15 minutes closes. I’ve tried it on a smartphone with Android 6.0.1 and in the android studio emulator with android 9.0 with the same result. Also say that I tried tricks like leaving the standard player running with an empty sound to see if it got it not to close, the same thing I did with the TaifunPlayer player letting it work with empty sound while exoplayer was playing. Always about 10 or 15 minutes it closed.

Yes, on some Chinese devices (eg Xiaomi, OnePlus) there are looping issues (gaps) with the TaifunPlayer. However, I had no problems with the ExoPlayer on any of my test devices (Android 4-10). Neither with looping nor stopping sound / music in sleep mode (standby). And my sounds / music have to play for a long time (hours).

Therefore, post a test AIA that replicates this issue. Which (test) devices and Android versions are you using? Did you test with APK or Companion?

i have received many Pm about that issue but still waiting for that to be get fixed,

2 Likes

Hi Anke, I have been creating a test aia. I tried first with just one Exoplayer player, and as you say, it didn’t seem to stop. By adding a second Exoplayer, it started to stop after 15 minutes or so. Although only one player is active, when I add 2, it stops.

On the devices I tried it with the apk are:
Physical device:
BQ Aquaris E5 4G with Android 6.0.1
Device emulated in AVD (Android Studio):
Pixel 3 with Android 9.0

ExoTest.aia (467.6 KB)
ExoTest.apk (5.8 MB)

Yes, I was able to reproduce this issue on a Samsung Galaxy Note8 (Android 9). However, the sound begins to stutter for me after about 50 seconds after I put the device into sleep mode. The sound then stops later. This issue does also occure with only one ExoPlayer.

The problem also arises on my device if the app moves into the background (i.e. after pressing the Home button). As soon as the charging cable is connected, the sound starts again. Also when I wake up the device again.

So connect the device to the charger and test …
It seems to be a problem with the energy saving options (on my Galaxy Note8).

See also here:
https://exoplayer.dev/troubleshooting.html#how-do-i-keep-audio-playing-when-my-app-is-backgrounded

Note: I have no issues with:

  • OnePlus 6 - Android 10
  • Xiaomi Redmi Note 5 - Android 9
  • Samsung Galaxy A3 (2017) - Android 8.0

I will check it out later on my other test devices …

3 Likes

Searching for information on your links and searching, I decided to try and add the permission:

“android.permission.FOREGROUND_SERVICE”

At the moment I have tried it on the AVD with android 9.0 and the application does not close. I will try the tests with my smartphone with android 6.0.1. I hope it works too. Can you confirm if your devices adding that permission work too?

FOREGROUND_SERVICE

Added in API level 28

public static final String FOREGROUND_SERVICE

Allows a regular application to use Service.startForeground .

Protection level: normal

Constant Value: “android.permission.FOREGROUND_SERVICE”

https://developer.android.com/reference/android/Manifest.permission.html#FOREGROUND_SERVICE

Yes, I have already seen that and tested. I declared this permission in the Manifest, unfortunately without success … you need a notification

see here:

1 Like

Have you tried adding the notifier that is in experimental?

What if you keep the screen from turning off?

It’s not a great solution, but until something else can be done…

Yes, of course this is always a possible solution, but the users do not like it, because this drains the battery faster. I have this option as the ultima ratio in all my apps and then let the app close automatically at the end to save the battery.

But the more interesting question is, why is that happening with ExoPlayer and not with MediaPlayer or TaifunPlayer?

Note: The Taifun Player is only a MediaPlayer (Player component) with a special (additional) function for seamless looping.

1 Like

Is there a reason, why you got a lot of PM for this issue? What was the content of these emails and why wasn’t it posted publicly? How should it be fixed if the Kodular team gets no knowledge of it?

I see no reason not to post this publicly, as this is a big problem with the ExoPlayer that makes it practically unusable. That should interest all users.

I spent a lot of time switching my app from App Inventor to Kodular. Fortunately, I have not yet updated my apps to the Kodular versions in the Play Store. Otherwise I would certainly have received many 1* ratings.

4 Likes

because users are sending me personally messages for there problems and many of them like making radio app for their radio station and they are facing same issue when radio stops automatically.

Thanks for the info, but that might be another issue that has arisen especially since Android 9 and is due to the fact that the WiFi connection is lost (throttled) in sleep mode.

See here:

https://groups.google.com/forum/#!searchin/mitappinventortest/mp3$20m4a|sort:date/mitappinventortest/Tz-h1ZysGxY/IrfB4PFEAwAJ

I have media player notification extension by @Ken, and the and music keep Stoping (when screen is off) after 40- 50 seconds on my Samsung A50.

Thanks, some questions:

  • which Android version (A50)?
  • which extension?
  • which adjustments have been made in the Manifest?
  • does the sound stop immediately after 50 sec or does it stutter first?
  • does the sound play again when the charging cable is plugged in or the device is woken up?

no issues with these too:

  • Nexus 5x - Android 8.1
  • Samsung Galaxy S6 - Android 7
  • Motorola Moto G - Android 5.1
  • Samsung Galaxy Alpha - Android 5.0
  • Samsung Galaxy Note 3 - Android 5.0

I will check it out later on my other test devices …

2 Likes

The MediaStyleNotification Extension just provides a notification with action buttons.
It doesn’t prevent the app or data connection from being killed by the OS.

2 Likes

The problem here seems to be about this:

1 Like

If anyone knows or finds a solution to this problem, it would be great and would help me and many others. I am happy to pay $ 100 for it.

3 Likes

Samsung a50 is running Android 9.

I haven’t added anything to fix this problem

The music stops after about 50 seconds after turn off the screen and sound start again after accessing the phone screen again, and I think it is a problem of new Samsung models, because I also had this problem with Spotify.
From the phone settings I have removed my application from the battery optimization and now it seems that the music no longer stops (PS: I didn’t test to let music for long time).

Yes, the sound play again.

Edit:

I tried too to add this permission, but without success too.

I hope this information will help you to solve this problem for everyone.

1 Like

It is also curious that even if you put another mediaplayer that does not have that problem, along with exoplayer, the added player does not prevent the app from closing.