Move all remote dependencies to be local (#220)

* Experiment with javascript bundling

* Experiment with snowpack. Making progress

* Success!  Uses local js modules and assets and no cdns

* Missing local css
This commit is contained in:
Gabe Kangas
2020-10-04 18:43:31 -07:00
committed by GitHub
parent e7f39a0113
commit 27a4c8c895
25 changed files with 8870 additions and 57 deletions
+12 -8
View File
@@ -1,5 +1,7 @@
// https://docs.videojs.com/player
import videojs from '/js/web_modules/videojs/dist/video.min.js';
const VIDEO_ID = 'video';
// TODO: This directory is customizable in the config. So we should expose this via the config API.
const URL_STREAM = `/hls/stream.m3u8`;
@@ -52,13 +54,14 @@ class OwncastPlayer {
}
init() {
videojs.Vhs.xhr.beforeRequest = function (options) {
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}`;
return options;
};
this.vjsPlayer = videojs(VIDEO_ID, VIDEO_OPTIONS);
this.addAirplay();
this.vjsPlayer.ready(this.handleReady);
}
@@ -75,10 +78,10 @@ class OwncastPlayer {
// play
startPlayer() {
this.log('Start playing');
const source = { ...VIDEO_SRC }
const source = { ...VIDEO_SRC };
this.vjsPlayer.src(source);
// this.vjsPlayer.play();
};
}
handleReady() {
this.log('on Ready');
@@ -117,7 +120,7 @@ class OwncastPlayer {
setPoster() {
const cachebuster = Math.round(new Date().getTime() / 1000);
const poster = POSTER_THUMB + "?okhi=" + cachebuster;
const poster = POSTER_THUMB + '?okhi=' + cachebuster;
this.vjsPlayer.poster(poster);
}
@@ -131,7 +134,6 @@ class OwncastPlayer {
if (window.WebKitPlaybackTargetAvailabilityEvent) {
var videoJsButtonClass = videojs.getComponent('Button');
var concreteButtonClass = videojs.extend(videoJsButtonClass, {
// The `init()` method will also work for constructor logic here, but it is
// deprecated. If you provide an `init()` method, it will override the
// `constructor()` method!
@@ -145,8 +147,10 @@ class OwncastPlayer {
},
});
var concreteButtonInstance = this.vjsPlayer.controlBar.addChild(new concreteButtonClass());
concreteButtonInstance.addClass("vjs-airplay");
var concreteButtonInstance = this.vjsPlayer.controlBar.addChild(
new concreteButtonClass()
);
concreteButtonInstance.addClass('vjs-airplay');
}
});
}