Skip to content

Conversation

@ghhccghk
Copy link
Contributor

@ghhccghk ghhccghk commented Aug 8, 2025

Code sources: https://github.com/Moriafly/media-kit and https://github.com/Yos-X/FlamingoSank

The functionality works as follows across different Android versions and OEM ROMs:

  • For Android 14 and higher, it uses MediaRouter2#showSystemOutputSwitcher.
  • For Android 12 and higher, it uses the “com.android.systemui.action.LAUNCH_MEDIA_OUTPUT_DIALOG” action.
  • For Android 11, it uses the “com.android.settings.panel.action.MEDIA_OUTPUT” action.
  • For MIUI (Xiaomi), it uses “miui.systemui.miplay.MiPlayDetailActivity”.
  • For One UI (Samsung), it uses “com.samsung.android.mdx.quickboard.view.MediaActivity”.

if (!tag) {
Toast.makeText(context, R.string.media_control_text_error, Toast.LENGTH_SHORT).show()
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this duplicated?

@ghhccghk
Copy link
Contributor Author

ghhccghk commented Aug 9, 2025

If you have any more questions, let's talk about them tomorrow. I'm going to bed now.

@nift4
Copy link
Member

nift4 commented Aug 15, 2025

@ghhccghk

Can you please:

  • move the output switcher button to the top right like you mentioned before
  • use .xml icon for output switcher instead of .png
  • remove xiaomi and samsung specific code for now, because it'll get stale and there's no way for me to know when xiaomi or samsung update their apis
  • use "git rebase" to update your pr branch on top of latest gramophone

thank you!

@ghhccghk
Copy link
Contributor Author

@ghhccghk

Can you please:

  • move the output switcher button to the top right like you mentioned before
  • use .xml icon for output switcher instead of .png
  • remove xiaomi and samsung specific code for now, because it'll get stale and there's no way for me to know when xiaomi or samsung update their apis
  • use "git rebase" to update your pr branch on top of latest gramophone

thank you!

OK, I have confirmed that Xiaomi will not remove the api, because this is one of their important interfaces for interconnection.

@ghhccghk ghhccghk force-pushed the pr branch 3 times, most recently from 0a17957 to deb62e0 Compare August 20, 2025 11:29
@nift4
Copy link
Member

nift4 commented Aug 27, 2025

So, the current problem is that it will show button for old device which never had output switcher. Like Android 5, 6, 7, 8, etc.

@ghhccghk
Copy link
Contributor Author

So, the current problem is that it will show button for old device which never had output switcher. Like Android 5, 6, 7, 8, etc.

Then add detection, and hide it if it is not supported

@nift4
Copy link
Member

nift4 commented Aug 27, 2025

Sure, I'll do it soon.

@ghhccghk
Copy link
Contributor Author

Sure, I'll do it soon.

OK

…cturers (OEMs)

Code sources: https://github.com/Moriafly/media-kit and https://github.com/Yos-X/FlamingoSank
The functionality works as follows across different Android versions and OEM ROMs:
- For Android 14 and higher, it uses MediaRouter2#showSystemOutputSwitcher.
- For Android 12 and higher, it uses the “com.android.systemui.action.LAUNCH_MEDIA_OUTPUT_DIALOG” action.
- For Android 11, it uses the “com.android.settings.panel.action.MEDIA_OUTPUT” action.
- For MIUI (Xiaomi), it uses “miui.systemui.miplay.MiPlayDetailActivity”.
- For One UI (Samsung), it uses “com.samsung.android.mdx.quickboard.view.MediaActivity”.
The SystemMediaControlResolver has been refactored to better handle various Android versions and OEM customizations. It also introduces dedicated checks for One UI versions and displays a Toast message when media output settings cannot be opened.

Specific changes include:

* The logic for launching the system media control dialog has been refactored into a new private function `startSystemMediaControl()`.
* Added a new function `getOneUIVersionReadable()` to retrieve the One UI version.
* Fall back to `startSystemMediaControl()` when launching OEM-specific media control dialogs fails.
* Display a Toast message when media output settings cannot be opened.
* Added new strings in `strings.xml`.
Moved the `getSystemProperties` logic into a separate private function for better readability and potential reuse. This change also ensures that an `IllegalArgumentException` is properly thrown if encountered during reflection.
The SystemMediaControlResolver has been refactored to better handle various Android versions and OEM customizations. It also introduces dedicated checks for One UI versions and displays a Toast message when media output settings cannot be opened.

Specific changes include:

* The logic for launching the system media control dialog has been refactored into a new private function `startSystemMediaControl()`.
* Added a new function `getOneUIVersionReadable()` to retrieve the One UI version.
* Fall back to `startSystemMediaControl()` when launching OEM-specific media control dialogs fails.
* Display a Toast message when media output settings cannot be opened.
* Added new strings in `strings.xml`.
…ml layout.

The media control buttons have been removed from the linear layout at the bottom of the screen and moved to the top of the screen. This button is now fixed at the top of the parent layout and has some margin for adjustment.
Temporarily disable One UI MediaActivity calls and wait until it is certain that they will not be deleted before adding them back.

Signed-off-by: ghhccghk <[email protected]>
Adjusted media output panel availability check logic based on Android version.

- For Android 14 and above, assume the panel is always available.
- For Android 12 and 13, check if the system UI can handle the media output dialog intent.
- For Android 11 and below, check if the Settings app can handle the media output panel intent.

If the panel is unavailable, hide the media control buttons.

Signed-off-by: ghhccghk <[email protected]>
@nift4
Copy link
Member

nift4 commented Oct 28, 2025

Hi, just to clarify what's the status: I think I will merge this after next release when I have more time. Reason is that 1. this is good opportunity to move more buttons around and migrate to proper TopAppBar in that screen, 2. as fallback I want to implement in-app output switcher (for A10 and earlier), 3. I want to check if it's possible to make MediaRouter allow to change between headphones and speaker before A15 in this output switcher, 4. for the previous point it would be good if Google fixed https://issuetracker.google.com/issues/340805981

Basically I want to check how much potential MediaRouter has before merging this feature, but I promise I will get back to you. Thank you for your patience!

@ghhccghk
Copy link
Contributor Author

Hi, just to clarify what's the status: I think I will merge this after next release when I have more time. Reason is that 1. this is good opportunity to move more buttons around and migrate to proper TopAppBar in that screen, 2. as fallback I want to implement in-app output switcher (for A10 and earlier), 3. I want to check if it's possible to make MediaRouter allow to change between headphones and speaker before A15 in this output switcher, 4. for the previous point it would be good if Google fixed https://issuetracker.google.com/issues/340805981

Basically I want to check how much potential MediaRouter has before merging this feature, but I promise I will get back to you. Thank you for your patience!

no problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants