From 1688b36e3999d368284841b1b55cc539ab8ee81c Mon Sep 17 00:00:00 2001 From: Muaz Ahmad Date: Tue, 22 Aug 2023 15:44:32 +0500 Subject: [PATCH] basic playlist loading --- hls-player.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 hls-player.js diff --git a/hls-player.js b/hls-player.js new file mode 100644 index 0000000..2086af9 --- /dev/null +++ b/hls-player.js @@ -0,0 +1,23 @@ +var player = document.getElementById('vid1'); + +class PlaylistLoader { + constructor() { + this.playlist_src = '/list/' + window.location.pathname.slice(6); + this.last_segment = null; + this.refresh_interval = null; + this.new_segments = []; + } + fetch_playlist() { + var xmlHttp = new XMLHttpRequest(); + xmlHttp.onreadystatechange = function() { + if (xmlHttp.readyState == 4 && xmlHttp.status == 200) { + console.log(xmlHttp.responseText); + } + } + xmlHttp.open("GET", this.playlist_src, true); + xmlHttp.send(null); + } +} + +var test = new PlaylistLoader(); +test.fetch_playlist()