class jessibucaPlayer { constructor(dom, options) { this.dom = dom this.url = options.url this.init() } init() { this.player = new Jessibuca({ container: this.dom, decoder:this.getSourceRootPath() + '/3rdparty/jessibuca/decoder.js', timeout: 30, heartTimeout: 30, heartTimeoutReplay: false, loadingTimeout: 30, loadingTimeoutReplay: false, wasmDecodeErrorReplay: false, videoBuffer: 0.2, // 缓存时长 isResize: false, text: "", loadingText: "", useMSE: false, debug: true, showBandwidth: false, // 显示网速 operateBtns: { fullscreen: false, screenshot: false, play: false, audio: false, recorder: false }, forceNoOffscreen: false, isNotMute: false, },); this.player.play(this.url); } on(Events, cd) { this.player.on(Events, cd) } destroy() { this.player.destroy() this.player = null } getSourceRootPath() { let sdkName = 'YJEarth.min.js' let scripts = document.querySelectorAll('script') let prefix = '' scripts.forEach((item) => { if (item.src && item.src.indexOf(sdkName) > -1) { let arr = item.src.split('/') arr.pop() prefix = arr.join('/') } }) return prefix } } export default jessibucaPlayer