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()