绍兴公厕前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
7.9 KiB

3 years ago
  1. function VideoMediaSource(a){function b(){}function c(){h()}function d(a){Q=[],Q.push({type:"error","function":q}),Q.push({type:"updateend","function":n}),Q.push({type:"update","function":o});for(var b=0;b<Q.length;b++)a.addEventListener(Q[b].type,Q[b]["function"])}function e(a){R=[],R.push({type:"durationchange","function":v}),R.push({type:"playing","function":s}),R.push({type:"error","function":r}),R.push({type:"pause","function":t}),R.push({type:"timeupdate","function":u}),R.push({type:"resize","function":w}),R.push({type:"seeked","function":x}),R.push({type:"waiting","function":y}),R.push({type:"canplaythrough","function":A}),R.push({type:"canplay","function":z}),R.push({type:"loadedmetadata","function":B});for(var b=0;b<R.length;b++)a.addEventListener(R[b].type,R[b]["function"])}function f(a){S=[],S.push({type:"sourceopen","function":c}),S.push({type:"error","function":p});for(var b=0;b<S.length;b++)a.addEventListener(S[b].type,S[b]["function"])}function g(){var a=0;if(null!==Q)for(a=0;a<Q.length;a++)ab.removeEventListener(Q[a].type,Q[a]["function"]);if(null!==S)for(a=0;a<S.length;a++)_.removeEventListener(S[a].type,S[a]["function"]);if(null!==R)for(a=0;a<R.length;a++)$.removeEventListener(R[a].type,R[a]["function"])}function h(){if(null===_||"ended"===_.readyState)return _=new MediaSource,f(_),$.src=window.URL.createObjectURL(_),void debug.log("videoMediaSource::appendInitSegment new MediaSource()");if(debug.log("videoMediaSource::appendInitSegment start"),0===_.sourceBuffers.length){_.duration=0;var a='video/mp4;codecs="avc1.'+E+'"';ab=_.addSourceBuffer(a),d(ab)}var b=D();return null===b?void _.endOfStream("network"):(ab.appendBuffer(b),void debug.log("videoMediaSource::appendInitSegment end, codecInfo = "+E))}function i(a){if(null!==ab&&"closed"!==_.readyState&&"ended"!==_.readyState)try{if(Y.length>0)return debug.count("1.segmentWaitDecode.length: "+Y.length),Y.push(a),void debug.count("2.segmentWaitDecode.length: "+Y.length);ab.updating?(debug.log("updating.........."),Y.push(a)):ab.appendBuffer(a)}catch(b){debug.log("videoMediaSource::appendNextMediaSegment error >> initVideo"),Y.length=0,W.initVideo(!1)}}function j(){$.paused&&(G(),T||$.play())}function k(){$.paused||U||(debug.log("pause"),$.pause())}function l(){var a=60,b=10,c=1*ab.buffered.start(ab.buffered.length-1),d=1*ab.buffered.end(ab.buffered.length-1);d-c>a&&ab.remove(c,d-b)}function m(){if(null!==_)try{if(ab&&ab.buffered.length>0&&(l(),X)){var a=1*ab.buffered.start(ab.buffered.length-1),b=1*ab.buffered.end(ab.buffered.length-1),c=0;if(c=0===$.currentTime?b-a:b-$.currentTime,c>=Z+.1){if(debug.log("跳秒"),ab.updating)return;var d=b-Z;$.currentTime=d.toFixed(3)}}}catch(e){debug.log("sourceBuffer has been removed")}}function n(){}function o(){Y.length>0&&(debug.count("1. onSourceUpdate .segmentWaitDecode.length: "+Y.length),ab.updating||(debug.count("2. onSourceUpdate .appendBuffer: "+Y.length+" "+Y[0].length),ab.appendBuffer(Y[0]),Y.shift()))}function p(){debug.log("videoMediaSource::onSourceError")}function q(){debug.log("videoMediaSource::onSourceBufferErrormsg")}function r(){debug.log("videoMediaSource::onError"),k()}function s(){T=!0,U=!1,debug.log("playing "),db||(db=!0,I("PlayStart"))}function t(){T=!1,U=!0,debug.log("暂停播放----------------------------------------------")}function u(){var a=4,b=4,c=parseInt(_.duration,10),d=parseInt($.currentTime,10),e=L.timestamp-K*(c-d+(1!==K?1:0)),f={timestamp:e,timestamp_usec:0,timezone:L.timezone};0===d||isNaN(c)||Math.abs(c-d)>b&&1===K||$.paused||(null===O?O=f:(O.timestamp<=f.timestamp&&K>=1||O.timestamp>f.timestamp&&1>K)&&(P&&W.timeStamp(f),O=f,V++,V>a&&H(f.timestamp,"currentTime")))}function v(){m()}function w(){G()}function x(){j()}function y(){if(debug.log("需要缓冲下一帧"),X=!1,0==cb)bb=Date.now(),cb++;else{cb++;var a=Date.now()-bb;debug.log("diffTime: "+a+" Count: "+cb),cb>=5&&6e4>a&&1.8>=Z&&(Z+=.1,cb=0,bb=0,debug.log("delay + 0.1 = "+Z))}}function z(){debug.log("Can play !")}function A(){debug.log("Can play without waiting"),X=!0}function B(){debug.log("loadedmetadata")}function C(