-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Add support for Android Auto *(season 2)* #12044
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
Conversation
Read the comments in the lines changed to understand more
Thanks @Stypox for this rewrite. I had a look at the code, and it looks good to me. I also tried testing it (so far only with the desktop head unit) and it seems to work well. I saw that it fixed the issues you originally raised e.g., with closing the player on the phone after starting it on android auto. At one attempt restarting playback didn't work, but in all other attempts it worked fine. Another thing I noticed (though I'm not sure if this wasn't happening before) is that if the player is paused, and I select a different item in Android Auto, in some cases it plays a couple of seconds from the old song before switching to the new one. Could this be related to the fix of onPrepare? |
Co-authored-by: Haggai Eran <[email protected]>
This changes significantly how the MediaSessionCompat and MediaSessionConnector objects are used: - now they are tied to the service and not to the player, and so they might be reused with multiple players (which should be allowed) - now they can exist even if there is no player (which is fundamental to be able to answer media browser queries)
Co-authored-by: Haggai Eran <[email protected]>
Co-authored-by: Haggai Eran <[email protected]>
Co-authored-by: Haggai Eran <[email protected]>
Co-authored-by: Haggai Eran <[email protected]>
This class will receive the media URLs generated by [MediaBrowserImpl] and will start playback of the corresponding streams or playlists. Co-authored-by: Haggai Eran <[email protected]> Co-authored-by: Profpatsch <[email protected]>
This class implements the media browser service interface as a standalone class for clearer separation of concerns (otherwise everything would need to go in PlayerService, since PlayerService overrides MediaBrowserServiceCompat) Co-authored-by: Haggai Eran <[email protected]> Co-authored-by: Profpatsch <[email protected]>
Now the media browser queries are replied to by MediaBrowserImpl Co-authored-by: Haggai Eran <[email protected]>
If a playbackPreparer is set, then instead of calling `player.prepare()`, the MediaSessionConnector will call `playbackPreparer.onPrepare(true)` instead, as seen below. This commit makes it so that playbackPreparer.onPrepare(true) restores the original behavior of just calling player.prepare(). From MediaSessionConnector -> MediaSessionCompat.Callback implementation: ```java @OverRide public void onPlay() { if (canDispatchPlaybackAction(PlaybackStateCompat.ACTION_PLAY)) { if (player.getPlaybackState() == Player.STATE_IDLE) { if (playbackPreparer != null) { playbackPreparer.onPrepare(/* playWhenReady= */ true); } else { player.prepare(); } } else if (player.getPlaybackState() == Player.STATE_ENDED) { seekTo(player, player.getCurrentMediaItemIndex(), C.TIME_UNSET); } Assertions.checkNotNull(player).play(); } } ```
This commit is a consequence of the commit "Drop some assumptions on how PlayerService is started and reused". Since the assumptions on how the PlayerService is started and reused have changed, we also need to adapt the way it is stopped. This means allowing the service to remain alive even after the player is destroyed, in case the system is still accessing PlayerService e.g. through the media browser interface. The foreground service needs to be stopped and the notification removed in any case.
Non-item errors, i.e. critical parsing errors of the page, are still handled properly.
I can't reproduce, but I have noticed this too in the current version of NewPipe (before this PR). I doubt it is caused by onPrepare, since I just rewired |
I can confirm that this works on actual HW, at least on Peugeot e2008. Really looking forward to the release. One improvment suggestion: When playing songs from the history list, the player displays the Prev and next arrows on the UI but they don't cause any action when pressed. Ideally they should change the song to next/prev on the history list or they should be grayed out if this is not feasible for some reason. |
Hi, I noticed a crash this morning that might be related to the changes in the service lifecycle. If I understand correctly, the video fragment's onDestroy triggers player service shutdown, which then attempts accessing the same fragment: Exception
Crash log
Note that this is from the first version of this PR, so maybe it was already fixed? |
Got this while testing new android auto implementation, but I have no idea if this is in any way related to the AA code. Exception
Crash log
|
Fixes mini-player not appearing on app start if the player service is already playing something. The PlayerService (and the player) may be started from an external intent that does not involve the MainActivity (e.g. RouterActivity or Android Auto's media browser interface). This PR tries to bind to the PlayerService as soon as the MainActivity starts, but only does so in a passive way, i.e. if the service is not already running it is not started. Once the connection between PlayerHolder and PlayerService is setup, the ACTION_PLAYER_STARTED broadcast is sent to MainActivity so that it can setup the bottom mini-player. Another important thing this commit does is to check whether the player is open before actually adding the mini-player view, since the PlayerService could be bound even without a running player (e.g. Android Auto's media browser is being used). This is a consequence of commit "Drop some assumptions on how PlayerService is started and reused".
This bug started appearing because the way to close the player is now unified in PlayerHolder.stopService(), which causes the player to reach back to the video detail fragment with a notification of the shutdown (i.e. onServiceStopped() is called). This is fixed by adding a nullability check on the binding.
This is, again, a consequence of the commit "Drop some assumptions on how PlayerService is started and reused". This commit notified VideoDetailFragment of player starting and stopping independently of the player. Read the comments in the code changes for more information.
This is not under our control, as starting from Android 13 (i.e. Tiramisu) the previous, next and play/pause actions are no longer customizable and are set by the system. Do other apps behave differently when there is only one song in queue?
Thanks, fixed in 126f4b0
This is unrelated, see #11803 I also pushed commits a7a7dc5 and 6558794 which update the code after the assumptions about how the player service is stopped and reused have changed (i.e. the service can now outlive the player). This fixes some rare crashes or unexpected behaviors. I tested this thoroughly and it miraculously seems to work without issues. I also added comments on every function I touched, so read those to understand the changes.
Fixed in 6558794. Note that this behavior was buggy before too, e.g. when the player was started from RouterActivity (i.e. the share menu) while MainActivity was not open. I could not find any open issue on our repo though. |
Hi, I tested the previous version (73f2cfa I guess) on my car as well, and it seemed to work well. I've also tested the new version (a7a7dc5) on the desktop-head-unit, and it also works great. I finally understood the comment about the square desktop-head-unit aspect ratio, and I was able to reproduce it, but I noticed that other apps also exhibit the same behavior. Could it be a problem in how Android Auto supports this aspect ratio? |
Wow, much needed feature! Thank you for your contribution! :) |
I installed the apk from the CI but my android auto is not showing New Pipe in the launcher. Did you guys do anything apart from install the apk to get it running? This is on a Pixel 9. Solved it: had to enable |
I think i found a solution to this |
I'm merging this, so it ends up in nightly APKs and gets tested by more people. Thank you again |
Hi excuse me, where can I find the new open request (conversation) / the new APK ? Thank you |
Hello, I am unable to start NewPipe on Android auto. |
@abesqaured which version are you on? This PR is still not in any official version but only in nightlies |
Thank you so much for your contribution, it's incredible. It would be great to include your subscription timeline. |
Could someone test #12412 on a real car, just to make sure the changes did not break anything? Can someone also comment on TeamNewPipe/website#399, explaning which steps (if any) they had to take to make NewPipe work on Android Auto? E.g. pinging @haggaie @abesqaured @sanchiro82 @harirah1 @asentes2 @notbasa @ready2code31 @oleg-d @frederikstonge @Occhioverde @andry23jsv (sorry for all the pings but we would be really thankful for quick feedback, as we plan to release a new NewPipe version within a week or so) |
Hi, I tested NewPipe nightly 0.27.7-1045-202507150127, is that okay? The Android Auto features worked well in my car, except for the History tab which didn't load, though I'm not sure if that was related to this change. |
Yes, nightly 0.27.7-1045-202507150127 is ok, thanks! About the History tab, 🤷 |
Hello,
in the last release 0.28.0 of newpipe, the history tab is not working, it
displays infinite load logo
Le lun. 7 juil. 2025 à 01:29, Stypox ***@***.***> a écrit :
… *Stypox* left a comment (TeamNewPipe/NewPipe#12044)
<#12044 (comment)>
Could someone test #12412
<#12412> on a real car, just
to make sure the changes did not break anything?
—
Reply to this email directly, view it on GitHub
<#12044 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMRDY2FEZVWCCOPLDFE2DVL3HGWPFAVCNFSM6AAAAABXHNG2NOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTANBTGEZTQNZYHE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Add support for Android Auto *(season 2)*
Add support for Android Auto *(season 2)*
…-auto" This reverts commit ddb318a.
What is it?
Description of the changes in your PR
Exposes media controls and playback status on Android Auto, as well as a basic browsing interface, showing playlists, history, and supporting basic searches.
This PR supersedes #9592, and the important differences lie in these commits: b764ad3, 6eb2920, dd29b73. Moreover, the
MediaBrowserConnector
was split into two mostly independent classes (MediaBrowserImpl
andMediaBrowserPlaybackPreparer
) which also have less confusing names. You can tell my new commits apart from what was already there in #9592 by looking at the commit Co-Authors.I tested with
desktop-head-unit
(also used for the screenshots below) and there do not seem to be player issues anymore (in particular, the player closes correctly in all ways it can be closed and never leaved behind an empty notification). I also tested a few other player use-cases and the behavior seems to be the same as current NewPipe.Issues, bugs, and missing features
When closing the player from its mini view, playback continues. It should be stopped instead.Fixed with the player changesWhen starting playback on Android Auto then opening the app, the mini player doesn't appear and isn't synchronized with the current state when "opened" (opening the details page of a content with autoplay disabled, pressing the play button plays the content on the details page)Fixed in 6558794Remote playlists are limited to their first page- This is unsolvable since Android Auto does not support pagination, but if you start playing a playlist (e.g. by clicking on a specific item) then the next pages will load in the queue.when starting the app then connecting to an Desktop Head Unit. The DHU was blocked on the loading step happening before showing playback controls normally, the app was playing the audio in the meantime then the app crashed.Fixed with the player changesIntegration with voice search- voice search from within the app works, but search from the google assistant (e.g., "play on NewPipe") only supports applications from the Google Play Store.Future enhancements
Before/After Screenshots/Screen Record
Fixes the following issue(s)
APK testing
The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR. You can find more info and a video demonstration on this wiki page.
Due diligence