Created
November 13, 2019 14:30
-
-
Save oberhamsi/af8ccef1275d553de84847798d2bbcb2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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