Update public/script.js
Browse files- public/script.js +17 -18
public/script.js
CHANGED
|
@@ -69,27 +69,26 @@ async function changeChannel(channel) {
|
|
| 69 |
}
|
| 70 |
|
| 71 |
const hls = new Hls({
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
|
| 81 |
hls.loadSource(streamUrl);
|
| 82 |
-
|
| 83 |
-
|
| 84 |
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
|
|
|
|
|
|
| 88 |
|
| 89 |
-
|
| 90 |
-
console.log(`Seeking to ${seekTime}s`);
|
| 91 |
-
videoPlayer.currentTime = seekTime;
|
| 92 |
-
});
|
| 93 |
|
| 94 |
hls.on(Hls.Events.ERROR, (event, data) => {
|
| 95 |
if (data.fatal) {
|
|
@@ -140,7 +139,7 @@ setInterval(async () => {
|
|
| 140 |
} catch (error) {
|
| 141 |
console.error("Failed to sync playback:", error);
|
| 142 |
}
|
| 143 |
-
},
|
| 144 |
|
| 145 |
function togglePlay() {
|
| 146 |
if (videoPlayer.paused) {
|
|
|
|
| 69 |
}
|
| 70 |
|
| 71 |
const hls = new Hls({
|
| 72 |
+
maxBufferLength: 60, // Reduce buffer length to avoid drastic jumps
|
| 73 |
+
maxMaxBufferLength: 120,
|
| 74 |
+
maxBufferSize: 200 * 1000 * 1000, // Reduce max buffer size
|
| 75 |
+
liveSyncDurationCount: 3, // Reduce to improve sync
|
| 76 |
+
enableWorker: true,
|
| 77 |
+
lowLatencyMode: true,
|
| 78 |
+
backBufferLength: 30 // Keep back buffer smaller
|
| 79 |
+
});
|
| 80 |
|
| 81 |
hls.loadSource(streamUrl);
|
| 82 |
+
hls.attachMedia(videoPlayer);
|
| 83 |
+
videoPlayer.hlsInstance = hls;
|
| 84 |
|
| 85 |
+
hls.on(Hls.Events.MANIFEST_PARSED, () => {
|
| 86 |
+
console.log(`Seeking to ${seekTime}s`);
|
| 87 |
+
videoPlayer.currentTime = seekTime; // Seek only once here
|
| 88 |
+
videoPlayer.play().catch(err => console.error("Playback error:", err));
|
| 89 |
+
});
|
| 90 |
|
| 91 |
+
// Remove BUFFER_APPENDED seeking to prevent repeated jumpsp
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
hls.on(Hls.Events.ERROR, (event, data) => {
|
| 94 |
if (data.fatal) {
|
|
|
|
| 139 |
} catch (error) {
|
| 140 |
console.error("Failed to sync playback:", error);
|
| 141 |
}
|
| 142 |
+
}, 363636366633626); // More frequent drift correction
|
| 143 |
|
| 144 |
function togglePlay() {
|
| 145 |
if (videoPlayer.paused) {
|