2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
|
var player,isLive=!1,autoplay=!1,videoPlayer,showControls=!1,speed=[.75,1,1.25,1.5],playerList=[],flvplayerList=[],createList=[],createing=!1,onlineCameraIndex=0,onlineIndex=0,playHistory=[],onlineTime,camTime,isSettingSwf=!1,refreshCount=0,isFull=!1,isAddLise=!1,audioId,playseek=0,isSetSeeked=!1,seekId,needSeek=!1,errorCount=0,intervalId=null,RECONNECT_TIME=4e3,onlineStatus="",onlineCameraStatus="",isShowAutoTip=!1;function createPlayer(t,e,n,r,a,l,i,s){if(t==null||t==null||t==""){console.log("\u64AD\u653E\u5668Id\u4E0D\u80FD\u4E3A\u7A7A");return}var c=$("#"+t),o=null;return c.length==0&&(o=document.createElement("VIDEO"),o.id=t),o}var flashChecker=function(){var t=/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent);if(t)return window.localStorage.setItem("isFlashPlayerError",1),{f:0,v:0};var e=0,n=0;if(document.all){var r=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");r&&(e=1,VSwf=r.GetVariable("$version"),n=parseInt(VSwf.split(" ")[1].split(",")[0]))}else if(navigator.plugins&&navigator.plugins.length>0){var r=navigator.plugins["Shockwave Flash"];if(r){e=1;for(var a=r.description.split(" "),l=0;l<a.length;++l)isNaN(parseInt(a[l]))||(n=parseInt(a[l]))}}return{f:e,v:n}},errorcallback;function init(t,e,n){var r={id:"",url:"",lang:"zh-cn",volume:.8,isLive:!1,playsinline:!0,whitelist:[""],autoplay:!0,fluid:!0,"x5-video-player-type":"h5","x5-video-player-fullscreen":"true","x5-video-orientation":"landscape",screenShot:!1,closeVideoClick:!0,closeVideoDblclick:!0,closeVideoTouch:!0,closePlayerBlur:!0,playbackRate:[.5,.75,1,1.5,2],defaultPlaybackRate:1,controls:!0,poster:""};r=extend(r,t,!0);var a=r.id;if(this["player"+a]=n?new FlvJsPlayer(r):new HlsJsPlayer(r),playerList.push(this["player"+a]),a==="online"){this["player"+a].on("ended",function(i){liveObj.cameraBackState(0,!1)}),this["player"+a].on("playbackrateChange",function(i){reviewWhiteSynCamera(a,"ratechange",i.to)}),this["player"+a].on("error",function(i){liveObj.cameraBackState(0,!0)}),this["player"+a].on("play",function(i){reviewWhiteSynCamera(a,"play")}),this["player"+a].on("stop",function(i){});var l=0;this["player"+a].on("timeupdate",function(i){try{var s=$("#online video")[0].currentTime;Math.abs(s-l)>1&&reviewWhiteSynCamera(a,"timeupdate"),l=s}catch(c){}}),this["player"+a].on("pause",function(i){reviewWhiteSynCamera(a,"pause")}),this["player"+a].on("playing",function(i){}),this["player"+a].on("waiting",function(i){})}this["player"+a].once("ready",()=>{e&&e()})}function reviewWhiteSynCamera(t,e,n){try{var r=window.location.href;if(r.indexOf("review.html")===-1)return;var a=getxgPlayer("onlineCamera");if(!a)return;switch(e){case"play":{a.play();break}case"pause":{a.pause();break}case"timeupdate":{$("#onlineCamera video")[0].currentTime=$("#online video")[0].currentTime;break}case"ratechange":{$("#onlineCamera video")[0].playbackRate=n;break}default:break}}catch(l){console.log("\u56DE\u770B\u540C\u6B65\u64CD\u4F5C\u5931\u8D25:",l)}}function changeMedia(){window.localStorage.setItem("isFlashPlayerError",1),location.reload()}function removeCreateListById(t){for(var e=0;e<createList.length;e++)createList[e].id===t&&createList.splice(e,1);createList.length>0&&init(createList[0].id,createList[0].playerType,createList[0].url,createList[0].isLive,createList[0].autoplay,createList[0].showControls,createList[0].thumbUrl,createList[0].callback)}var settingList=[],issettingURL=!1;function _setVideoUrl(t,e){issettingURL=!0;var n=e.split("?"),r=n[0];appU=r.split("/");var a=appU[appU.length-1],l=a.split("."),i="rtmp/flv";switch(l[l.length-1]){case"m3u8":i="application/x-mpegURL";break;case"flv":isLive=!0,i="rtmp/flv";break;case"mp4":i="video/mp4";break}getPlayer(t).src({src:e,type:i})}var volumeNumber=1,flashIsAdd=!1,flashErrorCount=0;function callJS(t,e){if(flashIsAdd=!0,t.search("online")>-1||t.search("interaction")>-1)switch(e){case"NetConnection.Connect.Success":break;case"NetConnection.Connect.Failed":t.search("onlineCamera")>-1?liveObj.cameraBackState(1,!0):t.search("interaction")>-1?getPlayer("online").hasOwnProperty("_type")&&getPlayer("online").
|