From 67c3f8ee38b1e3c8eb270c283228955c9996959b Mon Sep 17 00:00:00 2001 From: Matt Steele Date: Sat, 2 Jan 2021 13:30:29 -0600 Subject: [PATCH] Manually bust m3u8 caches (#570) Fixes #567 --- webroot/js/components/player.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/webroot/js/components/player.js b/webroot/js/components/player.js index a2d738d7b..bcab2fa4a 100644 --- a/webroot/js/components/player.js +++ b/webroot/js/components/player.js @@ -57,14 +57,16 @@ class OwncastPlayer { } init() { - this.vjsPlayer = videojs(VIDEO_ID, VIDEO_OPTIONS); - - this.vjsPlayer.beforeRequest = function (options) { - const cachebuster = Math.round(new Date().getTime() / 1000); - options.uri = `${options.uri}?cachebust=${cachebuster}`; + videojs.Vhs.xhr.beforeRequest = options => { + if (options.uri.match('m3u8')) { + const cachebuster = Math.round(new Date().getTime() / 1000); + options.uri = `${options.uri}?cachebust=${cachebuster}`; + } return options; }; + this.vjsPlayer = videojs(VIDEO_ID, VIDEO_OPTIONS); + this.addAirplay(); this.vjsPlayer.ready(this.handleReady); }