use of androidx.media3.common.util.BundleableUtil.fromNullableBundle in project media by androidx.
the class PlayerInfo method fromBundle.
private static PlayerInfo fromBundle(Bundle bundle) {
@Nullable PlaybackException playerError = BundleableUtil.fromNullableBundle(PlaybackException.CREATOR, bundle.getBundle(keyForField(FIELD_PLAYBACK_ERROR)));
int mediaItemTransitionReason = bundle.getInt(keyForField(FIELD_MEDIA_ITEM_TRANSITION_REASON), MEDIA_ITEM_TRANSITION_REASON_REPEAT);
SessionPositionInfo sessionPositionInfo = BundleableUtil.fromNullableBundle(SessionPositionInfo.CREATOR, bundle.getBundle(keyForField(FIELD_SESSION_POSITION_INFO)), SessionPositionInfo.DEFAULT);
PositionInfo oldPositionInfo = BundleableUtil.fromNullableBundle(PositionInfo.CREATOR, bundle.getBundle(keyForField(FIELD_OLD_POSITION_INFO)), SessionPositionInfo.DEFAULT_POSITION_INFO);
PositionInfo newPositionInfo = BundleableUtil.fromNullableBundle(PositionInfo.CREATOR, bundle.getBundle(keyForField(FIELD_NEW_POSITION_INFO)), SessionPositionInfo.DEFAULT_POSITION_INFO);
int discontinuityReason = bundle.getInt(keyForField(FIELD_DISCONTINUITY_REASON), DISCONTINUITY_REASON_AUTO_TRANSITION);
@Nullable Bundle playbackParametersBundle = bundle.getBundle(keyForField(FIELD_PLAYBACK_PARAMETERS));
PlaybackParameters playbackParameters = BundleableUtil.fromNullableBundle(PlaybackParameters.CREATOR, playbackParametersBundle, /* defaultValue= */
PlaybackParameters.DEFAULT);
@Player.RepeatMode int repeatMode = bundle.getInt(keyForField(FIELD_REPEAT_MODE), /* defaultValue= */
Player.REPEAT_MODE_OFF);
boolean shuffleModeEnabled = bundle.getBoolean(keyForField(FIELD_SHUFFLE_MODE_ENABLED), /* defaultValue= */
false);
Timeline timeline = BundleableUtil.fromNullableBundle(Timeline.CREATOR, bundle.getBundle(keyForField(FIELD_TIMELINE)), Timeline.EMPTY);
VideoSize videoSize = BundleableUtil.fromNullableBundle(VideoSize.CREATOR, bundle.getBundle(keyForField(FIELD_VIDEO_SIZE)), VideoSize.UNKNOWN);
MediaMetadata playlistMetadata = BundleableUtil.fromNullableBundle(MediaMetadata.CREATOR, bundle.getBundle(keyForField(FIELD_PLAYLIST_METADATA)), MediaMetadata.EMPTY);
float volume = bundle.getFloat(keyForField(FIELD_VOLUME), /* defaultValue= */
1);
AudioAttributes audioAttributes = BundleableUtil.fromNullableBundle(AudioAttributes.CREATOR, bundle.getBundle(keyForField(FIELD_AUDIO_ATTRIBUTES)), /* defaultValue= */
AudioAttributes.DEFAULT);
List<Cue> cues = BundleableUtil.fromBundleNullableList(Cue.CREATOR, bundle.getParcelableArrayList(keyForField(FIELD_CUES)), /* defaultValue= */
ImmutableList.of());
@Nullable Bundle deviceInfoBundle = bundle.getBundle(keyForField(FIELD_DEVICE_INFO));
DeviceInfo deviceInfo = BundleableUtil.fromNullableBundle(DeviceInfo.CREATOR, deviceInfoBundle, /* defaultValue= */
DeviceInfo.UNKNOWN);
int deviceVolume = bundle.getInt(keyForField(FIELD_DEVICE_VOLUME), /* defaultValue= */
0);
boolean deviceMuted = bundle.getBoolean(keyForField(FIELD_DEVICE_MUTED), /* defaultValue= */
false);
boolean playWhenReady = bundle.getBoolean(keyForField(FIELD_PLAY_WHEN_READY), /* defaultValue= */
false);
int playWhenReadyChangedReason = bundle.getInt(keyForField(FIELD_PLAY_WHEN_READY_CHANGED_REASON), /* defaultValue= */
PLAY_WHEN_READY_CHANGE_REASON_USER_REQUEST);
@Player.PlaybackSuppressionReason int playbackSuppressionReason = bundle.getInt(keyForField(FIELD_PLAYBACK_SUPPRESSION_REASON), /* defaultValue= */
PLAYBACK_SUPPRESSION_REASON_NONE);
@Player.State int playbackState = bundle.getInt(keyForField(FIELD_PLAYBACK_STATE), /* defaultValue= */
STATE_IDLE);
boolean isPlaying = bundle.getBoolean(keyForField(FIELD_IS_PLAYING), /* defaultValue= */
false);
boolean isLoading = bundle.getBoolean(keyForField(FIELD_IS_LOADING), /* defaultValue= */
false);
MediaMetadata mediaMetadata = BundleableUtil.fromNullableBundle(MediaMetadata.CREATOR, bundle.getBundle(keyForField(FIELD_MEDIA_METADATA)), MediaMetadata.EMPTY);
long seekBackIncrementMs = bundle.getLong(keyForField(FIELD_SEEK_BACK_INCREMENT_MS), /* defaultValue= */
0);
long seekForwardIncrementMs = bundle.getLong(keyForField(FIELD_SEEK_FORWARD_INCREMENT_MS), /* defaultValue= */
0);
long maxSeekToPreviousPosition = bundle.getLong(keyForField(FIELD_MAX_SEEK_TO_PREVIOUS_POSITION_MS), /* defaultValue= */
0);
TrackSelectionParameters trackSelectionParameters = BundleableUtil.fromNullableBundle(TrackSelectionParameters.CREATOR, bundle.getBundle(keyForField(FIELD_TRACK_SELECTION_PARAMETERS)), TrackSelectionParameters.DEFAULT_WITHOUT_CONTEXT);
return new PlayerInfo(playerError, mediaItemTransitionReason, sessionPositionInfo, oldPositionInfo, newPositionInfo, discontinuityReason, playbackParameters, repeatMode, shuffleModeEnabled, videoSize, timeline, playlistMetadata, volume, audioAttributes, cues, deviceInfo, deviceVolume, deviceMuted, playWhenReady, playWhenReadyChangedReason, playbackSuppressionReason, playbackState, isPlaying, isLoading, mediaMetadata, seekBackIncrementMs, seekForwardIncrementMs, maxSeekToPreviousPosition, trackSelectionParameters);
}
use of androidx.media3.common.util.BundleableUtil.fromNullableBundle in project media by androidx.
the class MediaSessionStub method subscribe.
@Override
public void subscribe(@Nullable IMediaController caller, int seq, String parentId, @Nullable Bundle libraryParamsBundle) {
if (caller == null) {
return;
}
if (TextUtils.isEmpty(parentId)) {
Log.w(TAG, "subscribe(): Ignoring empty parentId");
return;
}
@Nullable LibraryParams libraryParams = BundleableUtil.fromNullableBundle(LibraryParams.CREATOR, libraryParamsBundle);
dispatchSessionTaskWithLibrarySessionCommand(caller, seq, COMMAND_CODE_LIBRARY_SUBSCRIBE, (librarySessionImpl, controller) -> librarySessionImpl.onSubscribeOnHandler(controller, parentId, libraryParams), MediaSessionStub::sendLibraryResultWhenReady);
}
use of androidx.media3.common.util.BundleableUtil.fromNullableBundle in project media by androidx.
the class MediaSessionStub method getSearchResult.
@Override
public void getSearchResult(@Nullable IMediaController caller, int seq, String query, int page, int pageSize, @Nullable Bundle libraryParamsBundle) {
if (caller == null) {
return;
}
if (TextUtils.isEmpty(query)) {
Log.w(TAG, "getSearchResult(): Ignoring empty query");
return;
}
if (page < 0) {
Log.w(TAG, "getSearchResult(): Ignoring negative page");
return;
}
if (pageSize < 1) {
Log.w(TAG, "getSearchResult(): Ignoring pageSize less than 1");
return;
}
@Nullable LibraryParams libraryParams = BundleableUtil.fromNullableBundle(LibraryParams.CREATOR, libraryParamsBundle);
dispatchSessionTaskWithLibrarySessionCommand(caller, seq, COMMAND_CODE_LIBRARY_GET_SEARCH_RESULT, (librarySessionImpl, controller) -> librarySessionImpl.onGetSearchResultOnHandler(controller, query, page, pageSize, libraryParams), MediaSessionStub::sendLibraryResultWhenReady);
}
use of androidx.media3.common.util.BundleableUtil.fromNullableBundle in project media by androidx.
the class MediaSessionStub method search.
@Override
public void search(@Nullable IMediaController caller, int seq, String query, @Nullable Bundle libraryParamsBundle) {
if (caller == null) {
return;
}
if (TextUtils.isEmpty(query)) {
Log.w(TAG, "search(): Ignoring empty query");
return;
}
@Nullable LibraryParams libraryParams = BundleableUtil.fromNullableBundle(LibraryParams.CREATOR, libraryParamsBundle);
dispatchSessionTaskWithLibrarySessionCommand(caller, seq, COMMAND_CODE_LIBRARY_SEARCH, (librarySessionImpl, controller) -> librarySessionImpl.onSearchOnHandler(controller, query, libraryParams), MediaSessionStub::sendLibraryResultWhenReady);
}
use of androidx.media3.common.util.BundleableUtil.fromNullableBundle in project media by androidx.
the class MediaSessionStub method getLibraryRoot.
// ////////////////////////////////////////////////////////////////////////////////////////////
// AIDL methods for LibrarySession overrides
// ////////////////////////////////////////////////////////////////////////////////////////////
@Override
public void getLibraryRoot(@Nullable IMediaController caller, int seq, @Nullable Bundle libraryParamsBundle) throws RuntimeException {
if (caller == null) {
return;
}
@Nullable LibraryParams libraryParams = BundleableUtil.fromNullableBundle(LibraryParams.CREATOR, libraryParamsBundle);
dispatchSessionTaskWithLibrarySessionCommand(caller, seq, COMMAND_CODE_LIBRARY_GET_LIBRARY_ROOT, (librarySessionImpl, controller) -> librarySessionImpl.onGetLibraryRootOnHandler(controller, libraryParams), MediaSessionStub::sendLibraryResultWhenReady);
}
Aggregations