florent37/Flutter-AssetsAudioPlayer

CustomMediaButtonReceiver.onReceive

Opened this issue · 10 comments

Flutter Version
Flutter version : 3.13.1

Lib Version

Assets Audio Player version : 3.1.0

Platform (Android / iOS / web) + version

Platform : Android

Describe the bug

CustomMediaButtonReceiver.onReceive

Fatal Exception: android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException
Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{b4ae231 u0 com.goodvibes/com.github.florent37.assets_audio_player.notification.NotificationService}

Stack trace:

Fatal Exception: android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{b4ae231 u0 com.goodvibes/com.github.florent37.assets_audio_player.notification.NotificationService}
at android.app.ActivityThread.generateForegroundServiceDidNotStartInTimeException(ActivityThread.java:2245)
at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:2216)
at android.app.ActivityThread.-$$Nest$mthrowRemoteServiceException()
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2508)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8757)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

seceba commented

Hi, I'm getting the same problem 3.1.1 update is related to this error?

Hi, I'm getting the same problem 3.1.1 update is related to this error?
yes this problem didnot used to arise in the older version. @seceba

seceba commented

Version 3.0.6 does not have this problem. When I updated to version 3.1.0, I started to get this problem.

Also seeing this 'ForegroundServiceDidNotStartInTimeException' issue:

  • assets_audio_player: ^3.1.1
  • Flutter version 3.13.6
  • Dart version 3.1.3
  • Android 13 only (so far)
  • app is in the background (not the app's normal mode - it's a foreground-only app, so this may be the logic hole)

any updates?

My update is 'sideways' - try the 'just_audio' package instead.

That's not to say this is a bad package, but 'just_audio' worked for our particular simple requirements, with minimal code changes.

seceba commented

So I had to use another package. audioplayers this package sees it.

I did a PR which was already merged into master and even though it is focused on changes for Android 14 it might have fixed this issue as well.
Thus, I would ask some of those who experience the reported issue to try the version of this plugin from master pointing to my commit:

assets_audio_player:
    git:
      url: https://github.com/florent37/Flutter-AssetsAudioPlayer.git
      ref: 91638830570e5e3c2212d04fd99b8d3b60380dd3

@vbuberen Can you please share version so update version accordingly

Any updates?