diff --git a/example/dist/dist-play.js b/example/dist/dist-play.js index 814eaba2..0d8680aa 100644 --- a/example/dist/dist-play.js +++ b/example/dist/dist-play.js @@ -488,278 +488,6 @@ global.makeH265webjs = function (videoURL, config) { } }; - playerObj["do"](); - return playerObj; -}; -/*************************************************** - * - * - * - * 2. RAW HEVC DEMO - * HEVC/H.265, Demo for VOD, 点播文件播放demo - * - * - * - ***************************************************/ - - -var workerFetch = new Worker('./dist/worker-fetch-dist.js'); -var workerParse = new Worker('./dist/worker-parse-dist.js'); -console.log("workerFetch:", workerFetch); -console.log("workerParse:", workerParse); -/* - * 创建265流播放器 - */ - -global.makeH265webjsRaw = function (url265, config) { - var playerId = config.player; - - var playerObj = _index["default"].createPlayer(null, config); - - var playerDom = document.querySelector('#' + playerId); - var playerCont = document.querySelector('#player-container'); - var controllerCont = document.querySelector('#controller'); - var progressCont = document.querySelector('#progress-contaniner'); - var progressContW = progressCont.offsetWidth; - var cachePts = progressCont.querySelector('#cachePts'); - var progressPts = progressCont.querySelector('#progressPts'); - var progressVoice = document.querySelector('#progressVoice'); - var playBar = document.querySelector('#playBar'); - var playBtn = playBar.getElementsByTagName('a')[0]; - var showLabel = document.querySelector('#showLabel'); - var ptsLabel = document.querySelector('#ptsLabel'); - var coverToast = document.querySelector('#coverLayer'); - var coverBtn = document.querySelector('#coverLayerBtn'); - var muteBtn = document.querySelector('#muteBtn'); // let debugYUVBtn = document.querySelector('#debugYUVBtn'); - // let debugYUVATag = document.querySelector('#debugYUVUrl'); - - var fullScreenBtn = document.querySelector('#fullScreenBtn'); - var mediaInfo = null; - playBtn.disabled = true; - playBtn.textContent = '>'; - var muteState = false; // controllerCont.style.left = playerContainer.clientLeft; - // controllerCont.style.bottom = playerContainer.clientBottom; - // alert(playerContainer.clientLeft); - - var playAction = function playAction() { - console.log("is playing:", playerObj.isPlaying()); - - if (playerObj.isPlaying()) { - console.log("bar pause============>"); // playBar.textContent = '>'; - - playBar.setAttribute('class', 'playBtn'); - playerObj.pause(); - } else { - // playBar.textContent = '||'; - playBar.setAttribute('class', 'pauseBtn'); - playerObj.play(); - } - }; - - playerCont.onmouseover = function () { - controllerCont.hidden = false; - }; - - playerCont.onmouseout = function () { - controllerCont.hidden = true; - }; - - playerDom.onmouseup = function () { - playAction(); - }; - - playBtn.onclick = function () { - playAction(); - }; - - muteBtn.onclick = function () { - console.log(playerObj.getVolume()); - - if (muteState === true) { - playerObj.setVoice(1.0); - progressVoice.value = 100; - } else { - playerObj.setVoice(0.0); - progressVoice.value = 0; - } - - muteState = !muteState; - }; - - fullScreenBtn.onclick = function () { - playerObj.fullScreen(); - }; - - playerObj.onRender = function (width, height, imageBufferY, imageBufferB, imageBufferR) { - // screenView.render(width, height, imageBufferY, imageBufferB, imageBufferR); - console.log("on render"); - }; - - playerObj.onPlayTime = function (videoPTS) { - if (mediaInfo.videoType == "vod") { - // progressPts.value = videoPTS; - var precent = videoPTS / progressCont.max; - var progWidth = precent * progressContW; // console.log(precent, precent * progressCont.offsetWidth); - - progressPts.style.width = progWidth + 'px'; - ptsLabel.textContent = durationText(videoPTS) + '/' + durationText(progressCont.max); - } else { - // ptsLabel.textContent = durationText(videoPTS) + '/LIVE'; - ptsLabel.textContent = '/RAW'; - } - }; - - playerObj.onReadyShowDone = function () { - console.log("onReadyShowDone"); - showLabel.textContent = "Done"; - playBar.setAttribute('class', 'pauseBtn'); - }; - - playerObj.onLoadFinish = function () { - playerObj.setVoice(1.0); - mediaInfo = playerObj.mediaInfo(); - console.log("mediaInfo===========>", mediaInfo); - showLabel.textContent = "loading cover"; - /* - meta: - durationMs: 144400 - fps: 25 - sampleRate: 44100 - size: { - width: 864, - height: 480 - }, - audioNone : false - videoType: "vod" - */ - - playBar.disabled = false; - - if (mediaInfo.meta.audioNone) { - progressVoice.value = 0; - progressVoice.style.display = 'none'; - } - - if (mediaInfo.videoType == "vod") { - progressPts.max = mediaInfo.meta.durationMs / 1000; - ptsLabel.textContent = '0:0:0/' + durationText(progressPts.max); - } else { - cachePts.hidden = true; - progressCont.hidden = true; - ptsLabel.textContent = 'RAW'; - - if (mediaInfo.meta.audioNone === true) { - // playBar.textContent = '||'; - playerObj.play(); - } else { - coverToast.removeAttribute('hidden'); - - coverBtn.onclick = function () { - // playBar.textContent = '||'; - playerObj.play(); - coverToast.setAttribute('hidden', 'hidden'); - }; - } - } // showLabel.textContent = SHOW_DONE; - - - var fetchFinished = false; - var stopNaluInterval = false; - - var naluGetFunc = function naluGetFunc() { - setTimeout(function () { - workerParse.postMessage({ - cmd: "get-nalu", - data: null, - msg: "get-nalu" - }); - - if (stopNaluInterval === true) { - return; - } // naluGetFunc(); - - }, 1000); - }; - - workerFetch.onmessage = function (event) { - // console.log("play -> workerFetch recv:", event, playerObj); - var body = event.data; - var cmd = null; - - if (body.cmd === undefined || body.cmd === null) { - cmd = ''; - } else { - cmd = body.cmd; - } // console.log("play -> workerFetch recv cmd:", cmd); - - - switch (cmd) { - case 'fetch-chunk': - // console.log("play -> workerFetch append chunk"); - var chunk = body.data; - workerParse.postMessage({ - cmd: "append-chunk", - data: chunk, - msg: "append-chunk" - }); - break; - - case 'fetch-fin': - fetchFinished = true; - break; - - default: - break; - } - }; - - workerParse.onmessage = function (event) { - // return-nalu - // console.log("play -> workerParse recv:", event, playerObj); - var body = event.data; - var cmd = null; - - if (body.cmd === undefined || body.cmd === null) { - cmd = ''; - } else { - cmd = body.cmd; - } // console.log("play -> workerParse recv cmd:", cmd); - - - switch (cmd) { - case 'return-nalu': - var nalBuf = body.data; - - if (nalBuf === false || nalBuf === null || nalBuf === undefined) { - if (fetchFinished === true) { - stopNaluInterval = true; - } - } else { - // console.warn("play -> workerParse nalu"); - playerObj.append265NaluFrame(nalBuf); - workerParse.postMessage({ - cmd: "get-nalu", - data: null, - msg: "get-nalu" - }); - } - - break; - - default: - break; - } - }; - - workerFetch.postMessage({ - cmd: "start", - data: url265, - msg: "start" - }); - naluGetFunc(); - }; // onloadfinish - - playerObj["do"](); return playerObj; }; diff --git a/example/index.html b/example/index.html index 7e943206..1225d8be 100644 --- a/example/index.html +++ b/example/index.html @@ -124,6 +124,9 @@