shaka-player
shaka-player copied to clipboard
Is it possible to play a video chunk as soon as a response is received?
Have you read the Tutorials? yes
Have you read the FAQ and checked for duplicate open issues? yes
If the question is related to FairPlay, have you read the tutorial?
What version of Shaka Player are you using? 4.9.11
What browser and OS are you using? Window Chrome
Please ask your question I am using the live stream below. After meeting the 4-second buffer, playback is starting at a point where the remaining buffer is 3 seconds. But it always starts playing from the 6th video chunk. This appears to play the last 6th video chunk of the last downloaded playlist.
Is it possible to play directly from the 3rd video chunk?
await player.load(url);
this.videoElement.pause();
await this.ensurePlaybackBuffer(4);
this.videoElement.play();
async ensurePlaybackBuffer(minBufferLength) {
return new Promise((resolve) => {
const checkBuffer = () => {
const buffered = this.videoElement.buffered;
if (buffered.length > 0) {
const bufferEnd = buffered.end(buffered.length - 1);
const currentTime = this.videoElement.currentTime;
const bufferedAmount = bufferEnd - currentTime;
if (bufferedAmount >= minBufferLength) {
const targetTime = currentTime + 3;
if (bufferEnd > targetTime) {
this.videoElement.currentTime = targetTime;
} else {
}
resolve();
} else {
setTimeout(checkBuffer, 100);
}
} else {
setTimeout(checkBuffer, 100);
}
};
checkBuffer();
});
}
export function getDefaultConfig() {
return {
abr: { enabled: false },
streaming: {
bufferingGoal: 30,
rebufferingGoal: 5,
lowLatencyMode: true,
startAtSegmentBoundary: true,
liveSyncMaxLatency: 2,
updateIntervalSeconds: 0.5,
retryParameters: { baseDelay: 1000, timeout: 5000, maxAttempts: 2 },
},
manifest: {
hls: {
liveSegmentsDelay: 1,
},
retryParameters: { baseDelay: 1000, timeout: 5000, maxAttempts: 2 },
},
};
}
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:11121
#EXT-X-MAP:URI="https://test.com/beta-media/video/1920x1080/surplus.m4s"
#EXT-X-PROGRAM-DATE-TIME:2024-05-08T13:26:42.537Z
#EXTINF:1,
https://test.com/beta-media/video/1920x1080/11121.mp4v
#EXT-X-PROGRAM-DATE-TIME:2024-05-08T13:26:43.537Z
#EXTINF:1,
https://test.com/beta-media/video/1920x1080/11122.mp4v
#EXT-X-PROGRAM-DATE-TIME:2024-05-08T13:26:44.537Z
#EXTINF:1,
https://test.com/beta-media/video/1920x1080/11123.mp4v
#EXT-X-PROGRAM-DATE-TIME:2024-05-08T13:26:45.537Z
#EXTINF:1,
https://test.com/beta-media/video/1920x1080/11124.mp4v
#EXT-X-PROGRAM-DATE-TIME:2024-05-08T13:26:46.537Z
#EXTINF:1,
https://testcom/beta-media/video/1920x1080/11125.mp4v
#EXT-X-PROGRAM-DATE-TIME:2024-05-08T13:26:47.537Z
#EXTINF:1,
https://test.com/beta-media/video/1920x1080/11126.mp4v