Skip to content

Commit bf02a56

Browse files
committed
Fix a NullPointerException when the current metadata is null
Reload the play queue manager and set the recovery in this case, like on the current behavior (without this PR).
1 parent 015982b commit bf02a56

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

app/src/main/java/org/schabi/newpipe/player/Player.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4177,9 +4177,15 @@ private void useVideoSource(final boolean videoEnabled) {
41774177

41784178
final int videoRenderIndex = getVideoRendererIndex();
41794179

4180-
// We can safely assume that currentMetadata is not null (otherwise this method isn't
4181-
// called) so we can use the requireNonNull method of the Objects class.
4182-
final StreamInfo info = Objects.requireNonNull(currentMetadata).getMetadata();
4180+
// The current metadata may be null sometimes so we will be not able to execute the
4181+
// block above. Reload the play queue manager in this case.
4182+
if (currentMetadata == null) {
4183+
reloadPlayQueueManager();
4184+
setRecovery();
4185+
return;
4186+
}
4187+
4188+
final StreamInfo info = currentMetadata.getMetadata();
41834189

41844190
/* For video streams: we don't want to stream in background the video stream so if the
41854191
video stream played is not a video-only stream and if there is an audio stream available,

0 commit comments

Comments
 (0)