Skip to content

Instantly share code, notes, and snippets.

@oberhamsi
Created November 13, 2019 14:30
Show Gist options
  • Save oberhamsi/af8ccef1275d553de84847798d2bbcb2 to your computer and use it in GitHub Desktop.
Save oberhamsi/af8ccef1275d553de84847798d2bbcb2 to your computer and use it in GitHub Desktop.
class HlsWrapper {
constructor({element, url, startTime, context}) {
this.hls = new Hls({
debug: false,
autoStartLoad: false
});
const analyticsConfig = getAnalyticsConfig(context);
if (analyticsConfig) {
this.analytics = new HlsAdapter({
debug: false,
key: 'XXXXX',
...analyticsConfig
}, this.hls);
}
this.hls.attachMedia(element);
this.hls.on(Hls.Events.MEDIA_ATTACHED, () => {
this.hls.loadSource(url);
this.hls.once(Hls.Events.MANIFEST_PARSED, () => {
this.hls.startLoad(startTime || -1);
});
});
}
destroy() {
this.hls.destroy();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment