mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-11-05 09:36:22 +00:00
Implement Ignore hardware media button events option
This commit is contained in:
parent
2ee4c6e289
commit
42d861688e
@ -44,6 +44,15 @@ public class MediaSessionPlayerUi extends PlayerUi {
|
||||
sessionConnector = new MediaSessionConnector(mediaSession);
|
||||
sessionConnector.setQueueNavigator(new PlayQueueNavigator(mediaSession, player));
|
||||
sessionConnector.setPlayer(getForwardingPlayer());
|
||||
sessionConnector.setMediaButtonEventHandler((p, i) -> {
|
||||
// It seems like events from the Media Control UI
|
||||
// in the notification area don't go through this function,
|
||||
// so it's safe to just ignore all events in case we want to
|
||||
// ignore the hardware media buttons.
|
||||
// Returning true stops all further event processing of the system
|
||||
return player.getPrefs().getBoolean(
|
||||
context.getString(R.string.ignore_hardware_media_buttons_key), false);
|
||||
});
|
||||
|
||||
sessionConnector.setMetadataDeduplicationEnabled(true);
|
||||
sessionConnector.setMediaMetadataProvider(exoPlayer -> buildMediaMetadata());
|
||||
@ -53,6 +62,7 @@ public class MediaSessionPlayerUi extends PlayerUi {
|
||||
public void destroyPlayer() {
|
||||
super.destroyPlayer();
|
||||
if (sessionConnector != null) {
|
||||
sessionConnector.setMediaButtonEventHandler(null);
|
||||
sessionConnector.setPlayer(null);
|
||||
sessionConnector.setQueueNavigator(null);
|
||||
sessionConnector = null;
|
||||
|
@ -25,6 +25,7 @@
|
||||
<string name="screen_brightness_key">screen_brightness_key</string>
|
||||
<string name="screen_brightness_timestamp_key">screen_brightness_timestamp_key</string>
|
||||
<string name="clear_queue_confirmation_key">clear_queue_confirmation_key</string>
|
||||
<string name="ignore_hardware_media_buttons_key">ignore_hardware_media_buttons_key</string>
|
||||
|
||||
<string name="popup_saved_width_key">popup_saved_width</string>
|
||||
<string name="popup_saved_x_key">popup_saved_x</string>
|
||||
|
@ -83,6 +83,8 @@
|
||||
<string name="clear_queue_confirmation_title">Ask for confirmation before clearing a queue</string>
|
||||
<string name="clear_queue_confirmation_summary">Switching from one player to another may replace your queue</string>
|
||||
<string name="clear_queue_confirmation_description">The active player queue will be replaced</string>
|
||||
<string name="ignore_hardware_media_buttons_title">Ignore hardware media button events</string>
|
||||
<string name="ignore_hardware_media_buttons_summary">Useful, for instance, if you are using a headset with broken physical buttons</string>
|
||||
<string name="download_thumbnail_title">Load thumbnails</string>
|
||||
<string name="download_thumbnail_summary">Turn off to prevent loading thumbnails, saving data and memory usage. Changes clear both in-memory and on-disk image cache</string>
|
||||
<string name="show_comments_title">Show comments</string>
|
||||
|
@ -224,5 +224,12 @@
|
||||
app:singleLineTitle="false"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="@string/ignore_hardware_media_buttons_key"
|
||||
android:summary="@string/ignore_hardware_media_buttons_summary"
|
||||
android:title="@string/ignore_hardware_media_buttons_title"
|
||||
app:singleLineTitle="false"
|
||||
app:iconSpaceReserved="false" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
Loading…
Reference in New Issue
Block a user