mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Add MediaSessionConnector#setDispatchUnsupportedActionsEnabled(boolean)
This enables actions that are not advertised by the MediaSession to be dispatched either way. PiperOrigin-RevId: 379765015
This commit is contained in:
parent
56e97783eb
commit
6c05a469cb
1 changed files with 15 additions and 3 deletions
|
|
@ -487,6 +487,7 @@ public final class MediaSessionConnector {
|
||||||
|
|
||||||
private long enabledPlaybackActions;
|
private long enabledPlaybackActions;
|
||||||
private boolean metadataDeduplicationEnabled;
|
private boolean metadataDeduplicationEnabled;
|
||||||
|
private boolean dispatchUnsupportedActionsEnabled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an instance.
|
* Creates an instance.
|
||||||
|
|
@ -725,6 +726,14 @@ public final class MediaSessionConnector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether actions that are not advertised to the {@link MediaSessionCompat} will be
|
||||||
|
* dispatched either way. Default value is false.
|
||||||
|
*/
|
||||||
|
public void setDispatchUnsupportedActionsEnabled(boolean dispatchUnsupportedActionsEnabled) {
|
||||||
|
this.dispatchUnsupportedActionsEnabled = dispatchUnsupportedActionsEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether {@link MediaMetadataProvider#sameAs(MediaMetadataCompat, MediaMetadataCompat)}
|
* Sets whether {@link MediaMetadataProvider#sameAs(MediaMetadataCompat, MediaMetadataCompat)}
|
||||||
* should be consulted before calling {@link MediaSessionCompat#setMetadata(MediaMetadataCompat)}.
|
* should be consulted before calling {@link MediaSessionCompat#setMetadata(MediaMetadataCompat)}.
|
||||||
|
|
@ -949,13 +958,15 @@ public final class MediaSessionConnector {
|
||||||
|
|
||||||
@EnsuresNonNullIf(result = true, expression = "player")
|
@EnsuresNonNullIf(result = true, expression = "player")
|
||||||
private boolean canDispatchPlaybackAction(long action) {
|
private boolean canDispatchPlaybackAction(long action) {
|
||||||
return player != null && (enabledPlaybackActions & action) != 0;
|
return player != null
|
||||||
|
&& ((enabledPlaybackActions & action) != 0 || dispatchUnsupportedActionsEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EnsuresNonNullIf(result = true, expression = "playbackPreparer")
|
@EnsuresNonNullIf(result = true, expression = "playbackPreparer")
|
||||||
private boolean canDispatchToPlaybackPreparer(long action) {
|
private boolean canDispatchToPlaybackPreparer(long action) {
|
||||||
return playbackPreparer != null
|
return playbackPreparer != null
|
||||||
&& (playbackPreparer.getSupportedPrepareActions() & action) != 0;
|
&& ((playbackPreparer.getSupportedPrepareActions() & action) != 0
|
||||||
|
|| dispatchUnsupportedActionsEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EnsuresNonNullIf(
|
@EnsuresNonNullIf(
|
||||||
|
|
@ -964,7 +975,8 @@ public final class MediaSessionConnector {
|
||||||
private boolean canDispatchToQueueNavigator(long action) {
|
private boolean canDispatchToQueueNavigator(long action) {
|
||||||
return player != null
|
return player != null
|
||||||
&& queueNavigator != null
|
&& queueNavigator != null
|
||||||
&& (queueNavigator.getSupportedQueueNavigatorActions(player) & action) != 0;
|
&& ((queueNavigator.getSupportedQueueNavigatorActions(player) & action) != 0
|
||||||
|
|| dispatchUnsupportedActionsEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EnsuresNonNullIf(
|
@EnsuresNonNullIf(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue