fetch playlist on timer

This commit is contained in:
Muaz Ahmad 2023-08-23 11:55:04 +05:00
parent 4be364ce2e
commit f4c54fc43c

View file

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