function resizePlayer(){player&&(player.width(playerWidth()),player.height(playerHeight()))}function playerWidth(){return window.innerWidth}function playerHeight(){return window.innerHeight}function handleOrientationChange(){player.width(200),player.height(150),setTimeout(resizePlayer,100)}var hasFlash=!1,start=Date.now(),iOS=/(iPhone|iPad|iPod)/.test(navigator.userAgent),isAndroid=navigator.userAgent.toLowerCase().indexOf("android")>-1,playerIsActive=!1,player=null,STATES={UNKNOWN:"UNKNOWN",BROADCASTING:"BROADCASTING",BROADCAST_PENDING:"BROADCAST_PENDING",STOPPED:"STOPPED",STOP_PENDING:"STOP_PENDING",IP_EXEMPT_PAUSED:"IP_EXEMPT_PAUSED",IP_EXEMPT_PAUSE_PENDING:"IP_EXEMPT_PAUSE_PENDING"},pollCablecast=function(){$.get("/cablecastapi/v1/livestreams/"+TRMS.liveStreamId+"/status").then(function(n){n.state===STATES.STOPPED||n.state===STATES.IP_EXEMPT_PAUSED?hidePlayer(n.message):n.state===STATES.BROADCAST_PENDING?$("#player").html("<h3>Loading</h3><p>The stream is warming up and should be available shortly.</p>"):n.state===STATES.BROADCASTING&&playerIsActive===!1&&setupPlayer()}).always(function(){setTimeout(pollCablecast,5e3)})},hidePlayer=function(n){player&&(player.pause(),player.dispose(),player=null),$("#player").html(n),playerIsActive=!1},playerError=function(n){if(!n){$("#player").html("<h3>Error</h3><p>Configuration error. Cannot load the stream. Please refresh the page to try again.</p>"),player.dispose();return}$("#player").html("<h3>Error</h3><p>Something went wrong trying to load the stream. Please refresh the page to try again.</p>"),player.dispose()},setupPlayer=function(){if(!TRMS.streamUrl||TRMS.streamUrl.length<1){playerError();return}var t=TRMS.poster?'poster="'+TRMS.poster+'" ':"",n=TRMS.autoPlay?"autoplay":"";$("#player").html("<video  "+t+" "+n+' class="video-js vjs-default-skin vjs-big-play-centered" id="video"> <source src="'+TRMS.streamUrl+'" type="application/x-mpegURL" /></video>'),videojs("video",{techOrder:["html5"],width:playerWidth(),height:playerHeight(),controls:!0,autoplay:TRMS.autoPlay,html5:{hls:{overrideNative:!0}}},function(){player=this;player.on("error",playerError);player.on("ready",function(){reflectSetupMetrics(player)});player.textTracks().on("addtrack",function(n){n.track.kind==="captions"&&player.textTracks().removeTrack(n.track)})}),playerIsActive=!0};$(window).bind("resize",resizePlayer),$(window).bind("orientationchange",handleOrientationChange),TRMS.channelId&&$.get("/cablecastapi/v1/channels/"+TRMS.channelId).then(function(n){var t=n.channel.liveStreams;t.length>0&&(TRMS.liveStreamId=t[0],pollCablecast())})