diff options
Diffstat (limited to 'web/kbn_assets/app.js')
-rw-r--r-- | web/kbn_assets/app.js | 152 |
1 files changed, 7 insertions, 145 deletions
diff --git a/web/kbn_assets/app.js b/web/kbn_assets/app.js index 6081681..82b2db1 100644 --- a/web/kbn_assets/app.js +++ b/web/kbn_assets/app.js @@ -122,9 +122,8 @@ function indexInit() { } } -window.Cameras = { +var Cameras = { hlsOptions: null, - h265webjsOptions: null, host: null, proto: null, hlsDebugVideoEvents: false, @@ -185,126 +184,10 @@ window.Cameras = { } }, - setupH265WebJS: function(videoContainer, name) { - var containerHeightFixed = false; - var config = { - player: 'video-'+name, - width: videoContainer.offsetWidth, - height: parseInt(videoContainer.offsetWidth * 9 / 16, 10), - accurateSeek: true, - token: this.h265webjsOptions.token, - extInfo: { - moovStartFlag: true, - readyShow: true, - autoPlay: true, - rawFps: 15, - } - }; - - var mediaInfo; - var player = window.new265webjs(this.getUrl(name), config); - - player.onSeekStart = (pts) => { - console.log(name + ": onSeekStart:" + pts); - }; - - player.onSeekFinish = () => { - console.log(name + ": onSeekFinish"); - }; - - player.onPlayFinish = () => { - console.log(name + ": onPlayFinish"); - }; - - player.onRender = (width, height, imageBufferY, imageBufferB, imageBufferR) => { - // console.log(name + ": onRender"); - if (!containerHeightFixed) { - var ratio = height / width; - videoContainer.style.width = parseInt(videoContainer.offsetWidth * ratio, 10)+'px'; - containerHeightFixed = true; - } - }; - - player.onOpenFullScreen = () => { - console.log(name + ": onOpenFullScreen"); - }; - - player.onCloseFullScreen = () => { - console.log(name + ": onCloseFullScreen"); - }; - - player.onSeekFinish = () => { - console.log(name + ": onSeekFinish"); - }; - - player.onLoadCache = () => { - console.log(name + ": onLoadCache"); - }; - - player.onLoadCacheFinshed = () => { - console.log(name + ": onLoadCacheFinshed"); - }; - - player.onReadyShowDone = () => { - // console.log(name + ": onReadyShowDone:【You can play now】"); - player.play() - }; - - player.onLoadFinish = () => { - console.log(name + ": onLoadFinish"); - - player.setVoice(1.0); - - mediaInfo = player.mediaInfo(); - console.log("onLoadFinish mediaInfo===========>", mediaInfo); - - var codecName = "h265"; - if (mediaInfo.meta.isHEVC === false) { - console.log(name + ": onLoadFinish is Not HEVC/H.265"); - codecName = "h264"; - } else { - console.log(name + ": onLoadFinish is HEVC/H.265"); - } - - console.log(name + ": onLoadFinish media Codec:" + codecName); - console.log(name + ": onLoadFinish media FPS:" + mediaInfo.meta.fps); - console.log(name + ": onLoadFinish media size:" + mediaInfo.meta.size.width + "x" + mediaInfo.meta.size.height); - - if (mediaInfo.meta.audioNone) { - console.log(name + ": onLoadFinish media no Audio"); - } else { - console.log(name + ": onLoadFinish media sampleRate:" + mediaInfo.meta.sampleRate); - } - - if (mediaInfo.videoType == "vod") { - console.log(name + ": onLoadFinish media is VOD"); - console.log(name + ": onLoadFinish media dur:" + Math.ceil(mediaInfo.meta.durationMs) / 1000.0); - } else { - console.log(name + ": onLoadFinish media is LIVE"); - } - }; - - player.onCacheProcess = (cPts) => { - console.log(name + ": onCacheProcess:" + cPts); - }; - - player.onPlayTime = (videoPTS) => { - if (mediaInfo.videoType == "vod") { - console.log(name + ": onPlayTime:" + videoPTS); - } else { - // LIVE - } - }; - - player.do(); - // console.log('setupH265WebJS: video: ', video.offsetWidth, video.offsetHeight) - }, - init: function(opts) { this.proto = opts.proto; this.host = opts.host; this.hlsOptions = opts.hlsConfig; - this.h265webjsOptions = opts.h265webjsConfig; var useHls; if (opts.hlsConfig !== undefined) { @@ -315,33 +198,12 @@ window.Cameras = { } } - for (var camId in opts.camsByType) { - var name = camId + ''; - if (opts.isLow) - name += '-low'; - var type = opts.camsByType[camId]; - - switch (type) { - case 'h265': - var videoContainer = document.createElement('div'); - videoContainer.setAttribute('id', 'video-'+name); - videoContainer.setAttribute('style', 'position: relative'); // a hack to fix an error in h265webjs lib - videoContainer.className = 'video-container'; - document.getElementById('videos').appendChild(videoContainer); - try { - this.setupH265WebJS(videoContainer, name); - } catch (e) { - console.error('cam'+camId+': error', e) - } - break; - - case 'h264': - var video = document.createElement('video'); - video.setAttribute('id', 'video-'+name); - document.getElementById('videos').appendChild(video); - this.setupHls(video, name, useHls); - break; - } + for (var i = 0; i < opts.cams.length; i++) { + var camId = opts.cams[i]+'-low'; + var video = document.createElement('video'); + video.setAttribute('id', 'video-'+camId); + document.getElementById('videos').appendChild(video); + this.setupHls(video, camId, useHls); } }, |