From f4c54fc43c8b594d33f7aa8709b1618fd2835c95 Mon Sep 17 00:00:00 2001 From: Muaz Ahmad Date: Wed, 23 Aug 2023 11:55:04 +0500 Subject: [PATCH] fetch playlist on timer --- hls-player.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hls-player.js b/hls-player.js index 617e372..ad708db 100644 --- a/hls-player.js +++ b/hls-player.js @@ -6,6 +6,7 @@ class PlaylistLoader { this.last_segment = null; this.refresh_interval = null; this.new_segments = []; + this.fetch_playlist(); } fetch_playlist() { @@ -13,6 +14,7 @@ class PlaylistLoader { xmlHttp.onreadystatechange = ( function() { if (xmlHttp.readyState == 4 && xmlHttp.status == 200) { this.parse_playlist(xmlHttp.responseText); + setTimeout(this.fetch_playlist.bind(this), this.refresh_interval * 1000); } } ).bind(this) xmlHttp.open("GET", this.playlist_src, true); @@ -40,8 +42,7 @@ class PlaylistLoader { } this.new_segments = segments; this.last_segment = segments.at(-1); -} + } } var test = new PlaylistLoader(); -test.fetch_playlist()