Skip to content

Commit 8932adb

Browse files
committed
Apply suggested change and add a note about data consumption for HLS streams in background
ExoPlayer right now fetches HLS video tracks even if you disable them (with setRendererDisabled or setSelectionOverride). See issue 9282 of ExoPlayer's issue tracker for more information.
1 parent d27d36b commit 8932adb

1 file changed

Lines changed: 17 additions & 16 deletions

File tree

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

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3294,24 +3294,25 @@ public void onStartDrag(final PlayQueueItemHolder viewHolder) {
32943294
public MediaSource sourceOf(final PlayQueueItem item, final StreamInfo info) {
32953295
if (audioPlayerSelected()) {
32963296
return audioResolver.resolve(info);
3297-
} else {
3298-
if (isAudioOnly && videoResolver.getStreamSourceType().orElse(
3299-
SourceType.VIDEO_WITH_AUDIO_OR_AUDIO_ONLY)
3300-
== SourceType.VIDEO_WITH_AUDIO_OR_AUDIO_ONLY) {
3301-
// If the current info has only video streams with audio and if the stream is
3302-
// played as audio, we need to use the audio resolver, otherwise the video stream
3303-
// will be played in background.
3304-
return audioResolver.resolve(info);
3305-
}
3297+
}
33063298

3307-
// Even if the stream is played in background, we need to use the video resolver if the
3308-
// info played is separated video-only and audio-only streams; otherwise, if the audio
3309-
// resolver was called when the app was in background, the app will only stream audio
3310-
// when the user come back to the app and will never fetch the video stream.
3311-
// Note that the video is not fetched when the app is in background because the video
3312-
// renderer is fully disabled (see useVideoSource method).
3313-
return videoResolver.resolve(info);
3299+
if (isAudioOnly && videoResolver.getStreamSourceType().orElse(
3300+
SourceType.VIDEO_WITH_AUDIO_OR_AUDIO_ONLY)
3301+
== SourceType.VIDEO_WITH_AUDIO_OR_AUDIO_ONLY) {
3302+
// If the current info has only video streams with audio and if the stream is played as
3303+
// audio, we need to use the audio resolver, otherwise the video stream will be played
3304+
// in background.
3305+
return audioResolver.resolve(info);
33143306
}
3307+
3308+
// Even if the stream is played in background, we need to use the video resolver if the
3309+
// info played is separated video-only and audio-only streams; otherwise, if the audio
3310+
// resolver was called when the app was in background, the app will only stream audio when
3311+
// the user come back to the app and will never fetch the video stream.
3312+
// Note that the video is not fetched when the app is in background because the video
3313+
// renderer is fully disabled (see useVideoSource method), except for HLS streams
3314+
// (see https://github.com/google/ExoPlayer/issues/9282).
3315+
return videoResolver.resolve(info);
33153316
}
33163317

33173318
public void disablePreloadingOfCurrentTrack() {

0 commit comments

Comments
 (0)