Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error upon pressing media buttons from other apps #1242

Closed
2 tasks done
ARX-MM opened this issue Apr 1, 2018 · 10 comments · Fixed by #3178
Closed
2 tasks done

Error upon pressing media buttons from other apps #1242

ARX-MM opened this issue Apr 1, 2018 · 10 comments · Fixed by #3178
Labels
bug Issue is related to a bug player Issues related to any player (main, popup and background)

Comments

@ARX-MM
Copy link

ARX-MM commented Apr 1, 2018

  • I carefully read the contribution guidelines and agree to them.
  • I checked if the issue/feature exists in the latest version.

The app is unable to handle media buttons inputs that come from other apps installed. For example Kustom Live Wallpaper, Kustom Widget, Music Boss, and the Pebble app (with using a pebble smartwatch of course) crashes the app. The error reporter shows an ui error.

Might as well add a request since this bug needs some fixing and its related. Would be nice if Newpipe would share player details. Like for example what's the current song (or video) info (Title & Artist, track duration, and current track position) This info is quite useful for the apps mentioned above.

Here are the error details that the Newpipe reports.

{
   "user_action": "ui error",
   "request": "App crash, UI failure",
   "content_language": "US",
   "service": "none",
   "package": "org.schabi.newpipe",
   "version": "0.13.1",
   "os": "Linux Android 7.1.2 - 25",
   "time": "2018-04-01 21:33",
   "exceptions": [
      "java.lang.RuntimeException: Unable to start receiver android.support.v4.media.session.MediaButtonReceiver: java.lang.IllegalStateException: Could not find any Service that handles android.intent.action.MEDIA_BUTTON or implements a media browser service.\n\tat android.app.ActivityThread.handleReceiver(ActivityThread.java:3087)\n\tat android.app.ActivityThread.-wrap18(ActivityThread.java)\n\tat android.app.ActivityThread$H.handleMessage(ActivityThread.java:1591)\n\tat android.os.Handler.dispatchMessage(Handler.java:102)\n\tat android.os.Looper.loop(Looper.java:154)\n\tat android.app.ActivityThread.main(ActivityThread.java:6236)\n\tat java.lang.reflect.Method.invoke(Native Method)\n\tat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:891)\n\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:781)\n\tat de.robv.android.xposed.XposedBridge.main(XposedBridge.java:107)\nCaused by: java.lang.IllegalStateException: Could not find any Service that handles android.intent.action.MEDIA_BUTTON or implements a media browser service.\n\tat android.support.v4.media.session.MediaButtonReceiver.onReceive(MediaButtonReceiver.java:124)\n\tat android.app.ActivityThread.handleReceiver(ActivityThread.java:3080)\n\t... 9 more\njava.lang.IllegalStateException: Could not find any Service that handles android.intent.action.MEDIA_BUTTON or implements a media browser service.\n\tat android.support.v4.media.session.MediaButtonReceiver.onReceive(MediaButtonReceiver.java:124)\n\tat android.app.ActivityThread.handleReceiver(ActivityThread.java:3080)\n\tat android.app.ActivityThread.-wrap18(ActivityThread.java)\n\tat android.app.ActivityThread$H.handleMessage(ActivityThread.java:1591)\n\tat android.os.Handler.dispatchMessage(Handler.java:102)\n\tat android.os.Looper.loop(Looper.java:154)\n\tat android.app.ActivityThread.main(ActivityThread.java:6236)\n\tat java.lang.reflect.Method.invoke(Native Method)\n\tat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:891)\n\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:781)\n\tat"
   ],
   "user_comment": "¯\\_(ツ)_\/¯\n\nMaybe you should implement a player that can handle play\/pause commands from an external source.\n\nFor example, Kustom Live Wallpaper, Kustom Widget Maker, Pebble smartwatch. etc.\n\nCurrently the player crashes when pausing the stream using another app.\n\n the problem happens on both the YouTube and SoundCloud wrapper when playing video or audio only."
}

PS your report via email button is broken too. :P

@theScrabi
Copy link
Member

email button is fixed again.

@theScrabi
Copy link
Member

@karyogamy implemented media button interface in v0.13.0 I wonder why its not working.

@karyogamy
Copy link
Contributor

karyogamy commented Apr 2, 2018

@theScrabi
My guess is @axel2230 is trying to create custom widget to start playback on newpipe, when no player is actually running. (Please correct me if I'm wrong) This is not supported at the moment since we are not implementing MediaBrowserService on the players, and I think it's probably better to do this once we merged all the players though. I'll take a look into this once I have a good chunk of free time, since this is not as trivial as I previously have thought.

@ARX-MM
Copy link
Author

ARX-MM commented Apr 3, 2018

@karyogamy, Umm that isn't actually the case. I'm well aware of trying to start a player when no content is previously playing causes issues even with other apps. My custom widget is designed to just control the state of the current player only when there is some content loaded. Like for example pausing a song that is running and then resuming it a minute or two later.

The issue crops up immediately after pressing pause, and i tested it out and the same goes for recently paused content and then pressing play.

Either way the error appears in anyway I try Pausing, Resuming and Starting Playback (which again is something I don't actually do.) It seems newpipe only wants me to control it inside the app or through the notification controls. Any other control inputs that aren't from the app itself causes a crash.

@karyogamy
Copy link
Contributor

From the media button reciever reference page:

This class assumes you have a Service in your app that controls media playback via a MediaSessionCompat. Once a key event is received by MediaButtonReceiver, this class tries to find a Service that can handle ACTION_MEDIA_BUTTON, and a MediaBrowserServiceCompat in turn. If an appropriate service is found, this class forwards the key event to the service. If neither is available or more than one valid service/media browser service is found, an IllegalStateException will be thrown.

So, it's possible that the error you are seeing is stemming from the manifest not having those intent filters on the player services. However, I am unable to reproduce the exception since the media controls on Kustom Live Wallpaper and Kustom Widget doesn't seem to work on my devices, so I can't verify that this issue is resolved. That being said, the manifest will be updated with the intent filters, so they are consistent with the reference implementation.

@ARX-MM
Copy link
Author

ARX-MM commented Apr 3, 2018

Try setting the preferred music player to NewPipe in Kustom widget or Kustom Live Wallpaper. It should force the play/pause commands directly into newpipe.

@karyogamy
Copy link
Contributor

karyogamy commented Apr 3, 2018

That fixed it, thanks =D And here's the fix.

This change designates the background player as our default player when a media button event from an external app is directed at newpipe, so maybe we will need to discuss about this.

Still, starting playback when the player is not running is still not working, though it won't crash the app anymore. We can later have another PR to introduce play queue saving on player exit, along with a proper media browser service.

@ARX-MM
Copy link
Author

ARX-MM commented Apr 3, 2018

Nice, let's see hopefully both problems doesn't crop up again.

That queue idea sounds amazing. I'll keep an eye out for it then. ;)

@stale
Copy link

stale bot commented Dec 1, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 1, 2018
@TobiGr TobiGr removed the stale label Jul 19, 2019
@Stypox Stypox added the bug Issue is related to a bug label Jul 19, 2019
@Stypox Stypox added the player Issues related to any player (main, popup and background) label Aug 27, 2019
@Stypox Stypox linked a pull request Aug 12, 2020 that will close this issue
1 task
@Stypox
Copy link
Member

Stypox commented Aug 12, 2020

Could you test if #3178 fixes this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is related to a bug player Issues related to any player (main, popup and background)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants