Merge pull request #10577 from AudricV/fix-npe-play-queue-audio-track-menu

Fix crash when building the play queue audio track menu if the player is null
This commit is contained in:
Stypox 2023-11-16 09:01:11 +01:00 committed by GitHub
commit 3dc593fe88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -619,11 +619,13 @@ public final class PlayQueueActivity extends AppCompatActivity
final MenuItem audioTrackSelector = menu.findItem(R.id.action_audio_track);
final List<AudioStream> availableStreams =
Optional.ofNullable(player.getCurrentMetadata())
Optional.ofNullable(player)
.map(Player::getCurrentMetadata)
.flatMap(MediaItemTag::getMaybeAudioTrack)
.map(MediaItemTag.AudioTrack::getAudioStreams)
.orElse(null);
final Optional<AudioStream> selectedAudioStream = player.getSelectedAudioStream();
final Optional<AudioStream> selectedAudioStream = Optional.ofNullable(player)
.flatMap(Player::getSelectedAudioStream);
if (availableStreams == null || availableStreams.size() < 2
|| selectedAudioStream.isEmpty()) {