
﻿
function livestreamPlayerCallback(event)
{if(event=='ready')
{tvPlayerApi.setVolume(tvPlayerVolume);tvPlayerApi.setMute(tvPlayerIsMute);if(tvPlayerIsPlaying)
tvPlayerApi.startPlayback(0);}}
function setContentTitle()
{var title=null;if(!tvPlayerIsBroadcastingLive)
title=onDemandVars.title;else try
{title=tvPlayerApi.getCurrentContentTitle();}
catch(e){}
if(title==null)
setTimeout(setContentTitle,10000);else
{$("#TVContentTitle").text(title);setTimeout(setContentTitle,15000);}}
function forceContentTitle(title)
{$("#TVContentTitle").text(title);}
var onDemandVars={title:null}
function playOnDemandVideo(guid,title)
{onDemandVars.title=title;forceContentTitle(title);tvPlayerIsBroadcastingLive=false;tvPlayerApi.setClipID(guid);tvPlayerApi.startPlayback(0);$("#TVisLive").css("display","none");$("#TVisOnDemand").css("display","block");}
function playLive()
{forceContentTitle("");tvPlayerIsBroadcastingLive=false;tvPlayerApi.setClipID(null);tvPlayerApi.startPlayback(0);$("#TVisOnDemand").css("display","none");$("#TVisLive").css("display","block");}
var liveThumbRotVars={jimg:null,time:0,updateThumbnailRef:null}
var onDemandThumbRotVars={jimg:null,time:0,updateThumbnailRef:null,guid:null}
var updateLiveThumbnail=function(){updateThumbnail(liveThumbRotVars)}
var updateOnDemandThumbnail=function(){updateThumbnail(onDemandThumbRotVars)}
function updateThumbnail(params)
{if(params.guid!=null)
params.jimg.attr("src","http://clipthumbnail.api.livestream.com/?clipID="+params.guid+"&channel="+tvChannelName+"&time="+params.time);else
params.jimg.attr("src","http://thumbnail.api.livestream.com/thumbnail?name="+tvChannelName+"&t="+Math.floor(Math.random()*10000));params.time+=20;if(params.time>120)
params.time=0;}
function startLiveThumbnailRotation(interval,jimg)
{liveThumbRotVars.jimg=jimg;liveThumbRotVars.time=0;jimg.attr("src","Images/Master/TVMiniNoSignal.jpg");setTimeout(updateLiveThumbnail,3000);liveThumbRotVars.updateThumbnailRef=setInterval(updateLiveThumbnail,interval);}
function startOnDemandThumbnailRotation(interval,jimg,guid)
{onDemandThumbRotVars.jimg=jimg;onDemandThumbRotVars.time=0;onDemandThumbRotVars.guid=guid;updateOnDemandThumbnail();onDemandThumbRotVars.updateThumbnailRef=setInterval(updateOnDemandThumbnail,interval);}
function stopLiveThumbnailRotation()
{clearInterval(liveThumbRotVars.updateThumbnailRef);}
function stopOnDemandThumbnailRotation()
{clearInterval(onDemandThumbRotVars.updateThumbnailRef);}
var tvChannelName;var tvPlayerApi;var tvPlayerVolume;var tvPlayerIsMute;var tvPlayerIsPlaying;var tvPlayerIsBroadcastingLive=true;function StartLivestreamTV()
{var jelem;jelem=$("#TVChannelName");if(jelem.length!=0)
tvChannelName=jelem.val();if($("#TVPlayerOutput").length!=0)
{tvPlayerVolume=parseFloat($("#TVPlayerVolume").val());tvPlayerIsMute=$("#TVPlayerIsMute").val()=="true"?true:false;tvPlayerIsPlaying=$("#TVPlayerIsPlaying").val()=="true"?true:false;var api=$("#TVPlayerEmbedPlaceHolder").flashembed({src:"http://cdn.livestream.com/chromelessPlayer/wrappers/JSPlayer.swf",expressInstall:"Flash/ExpressInstall.swf",allowfullscreen:"true",allowscriptaccess:"always",wmode:"opaque"},{devKey:'wdWBGRcXyfmRBgfiZpL9ttMZWl5iQFhoggDGNJrMTbwmoUUKJaqihB-MrcOB8NC2ALJD60-KYPiGZOWTW4xbVwmaNVFAP-WdlMrKR3WsSGk',channel:tvChannelName});tvPlayerApi=api.getApi();}
if($("#TVContentTitle").length!=0)
setTimeout(setContentTitle,10000);jelem=$("#TVThumbnailImg");if(jelem.length!=0)
startLiveThumbnailRotation(15000,jelem)}
$(document).ready(function()
{setTimeout(StartLivestreamTV,3000);});
