var playlist={streams:[],titles:[],pos:-1};function init(passIf){(playlist.streams.length>0||!0===passIf)&&(-1!=playlist.streams[0].indexOf("m3u8")?(console.log("hls"),hlsLoad()):(console.log("dash"),initApp()))}function setupShakaEvents(player){player.addEventListener("loaded",()=>mediaController.setLoader(!1)),player.addEventListener("loading",()=>mediaController.setLoader(!0)),player.addEventListener("buffering",_=>mediaController.setLoader(_.buffering))}function initApp(){if(shaka.polyfill.installAll(),shaka.Player.isBrowserSupported()){var player=initPlayer();window.player=player,setupShakaEvents(player),doPlay(player,pushNext())}else console.error("Browser not supported!")}function initPlayer(){var video=document.getElementById("video_player_id"),player=new shaka.Player(video);return player.addEventListener("error",onErrorEvent),video.addEventListener("ended",(function(){player.unload(),doPlay(player,pushNext())})),player}function doPlay(player,src){player.load(src.manifest).then((function(){console.log("Manifest Loaded Successfully")})).catch(onError)}function pushNext(){return playlist.pos++,playlist.pos>playlist.streams.length-1&&(playlist.pos=0),{manifest:playlist.streams[playlist.pos],title:playlist.titles[playlist.pos]}}function onErrorEvent(event){onError(event.detail)}function onError(error){console.error("Error code",error.code,"object",error),console.info("Retrying..."),2===error.severity&&(console.warn("Forcing Retry... Please Wait..."),location.reload())}function onHlsError(hls,event,data){switch(mediaController.setLoader(!0),data.type){case Hls.ErrorTypes.NETWORK_ERROR:console.log("fatal network error encountered, try to recover"),hls.startLoad();break;case Hls.ErrorTypes.MEDIA_ERROR:console.log("fatal media error encountered, try to recover"),hls.recoverMediaError();break;default:console.log("couldn't recovered"),hls.destroy(),mediaController.forceRetry()}}function setupEvents(HLSPlayer){null!==HLSPlayer&&(console.log("setting up"),HLSPlayer.on(window.Hls.Events.FRAG_BUFFERED||window.Hls.Events.FRAG_LOADED||window.Hls.Events.LEVEL_LOADED,()=>{mediaController.setLoader(!1)}))}function configPlayer(){window.Hls.DefaultConfig={...window.Hls.DefaultConfig,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrEwmaDefaultEstimate:5e5,abrEwmaFastLive:3,abrEwmaFastVoD:3,abrEwmaSlowLive:9,abrEwmaSlowVoD:9,abrMaxWithRealBitrate:!1,appendErrorMaxRetry:3,autoStartLoad:!0,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,defaultAudioCodec:void 0,emeEnabled:!1,enableCEA708Captions:!0,enableSoftwareAES:!0,enableWebVTT:!0,enableWorker:!0,fLoader:void 0,forceKeyFrameOnDiscontinuity:!0,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,fragLoadingMaxRetry:6,fragLoadingMaxRetryTimeout:64e3,fragLoadingRetryDelay:1e3,fragLoadingTimeOut:2e4,highBufferWatchdogPeriod:3,initialLiveManifestSize:1,levelLoadingMaxRetry:4,levelLoadingMaxRetryTimeout:64e3,levelLoadingRetryDelay:1e3,levelLoadingTimeOut:1e4,licenseXhrSetup:void 0,liveDurationInfinity:!1,liveMaxLatencyDuration:void 0,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveSyncDurationCount:3,lowBufferWatchdogPeriod:.5,manifestLoadingMaxRetry:1,manifestLoadingMaxRetryTimeout:64e3,manifestLoadingRetryDelay:1e3,manifestLoadingTimeOut:1e4,maxAudioFramesDrift:1,maxBufferHole:.5,maxBufferLength:30,maxBufferSize:6e7,maxFragLookUpTolerance:.25,maxLoadingDelay:4,maxMaxBufferLength:600,maxStarvationDelay:4,minAutoBitrate:0,nudgeMaxRetry:3,nudgeOffset:.1,pLoader:void 0,requestMediaKeySystemAccessFunc:null,startFragPrefetch:!1,startLevel:void 0,startPosition:-1,stretchShortVideoTrack:!1}}function hlsLoad(stream){if(Hls.isSupported()){var video=document.getElementById("video_player_id");configPlayer();var hls=new Hls;hls.loadSource(playlist.streams[0]),hls.attachMedia(video),hls.on(Hls.Events.MANIFEST_PARSED,(function(){console.log("MANIFEST_PARSED")})),hls.on(Hls.Events.ERROR,(event,data)=>onHlsError(hls,event,data)),setupEvents(hls),window.HlsPlayer=hls}else initApp()}