Skip to content

Commit f0bb2e8

Browse files
authored
Merge pull request #6307 from TeamNewPipe/peertube_hls
Add support for PeerTube HLS streams
2 parents 4643cce + 87d2f33 commit f0bb2e8

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ dependencies {
183183
/** NewPipe libraries **/
184184
// You can use a local version by uncommenting a few lines in settings.gradle
185185
implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751'
186-
implementation 'com.github.TeamNewPipe:NewPipeExtractor:3a3ade20f48cf37526eb970a7df56ee2405125fc'
186+
implementation 'com.github.TeamNewPipe:NewPipeExtractor:636e27333b5dbd9bc3c54ef3a4c21a87e97253ee'
187187

188188
/** Checkstyle **/
189189
checkstyle "com.puppycrawl.tools:checkstyle:${checkstyleVersion}"

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
import org.schabi.newpipe.extractor.MediaFormat;
9292
import org.schabi.newpipe.extractor.stream.StreamInfo;
9393
import org.schabi.newpipe.extractor.stream.StreamSegment;
94+
import org.schabi.newpipe.extractor.stream.StreamType;
9495
import org.schabi.newpipe.extractor.stream.VideoStream;
9596
import org.schabi.newpipe.fragments.OnScrollBelowItemsListener;
9697
import org.schabi.newpipe.fragments.detail.VideoDetailFragment;
@@ -1632,9 +1633,22 @@ private void triggerProgressUpdate() {
16321633
if (exoPlayerIsNull()) {
16331634
return;
16341635
}
1636+
// Use duration of currentItem for non-live streams,
1637+
// because HLS streams are fragmented
1638+
// and thus the whole duration is not available to the player
1639+
// TODO: revert #6307 when introducing proper HLS support
1640+
final int duration;
1641+
if (currentItem != null
1642+
&& currentItem.getStreamType() != StreamType.AUDIO_LIVE_STREAM
1643+
&& currentItem.getStreamType() != StreamType.LIVE_STREAM) {
1644+
// convert seconds to milliseconds
1645+
duration = (int) (currentItem.getDuration() * 1000);
1646+
} else {
1647+
duration = (int) simpleExoPlayer.getDuration();
1648+
}
16351649
onUpdateProgress(
16361650
Math.max((int) simpleExoPlayer.getCurrentPosition(), 0),
1637-
(int) simpleExoPlayer.getDuration(),
1651+
duration,
16381652
simpleExoPlayer.getBufferedPercentage()
16391653
);
16401654
}

0 commit comments

Comments
 (0)