Browse Source

用解析不卡播放

simplify_dependencies
巴林闲侠 2 years ago
parent
commit
8c9c425c9a
  1. 8202
      console/client/assets/js/jessibuca/decoder.js
  2. BIN
      console/client/assets/js/jessibuca/decoder.wasm
  3. 13126
      console/client/assets/js/jessibuca/jessibuca.js
  4. 1
      console/client/assets/js/jessibuca/manifest.json
  5. 2
      console/client/index.html
  6. 139
      console/client/src/sections/console/containers/index.js

8202
console/client/assets/js/jessibuca/decoder.js

File diff suppressed because one or more lines are too long

BIN
console/client/assets/js/jessibuca/decoder.wasm

Binary file not shown.

13126
console/client/assets/js/jessibuca/jessibuca.js

File diff suppressed because one or more lines are too long

1
console/client/assets/js/jessibuca/manifest.json

@ -0,0 +1 @@
{}

2
console/client/index.html

@ -1,4 +1,4 @@
<!DOCTYPE html> <!-- <!DOCTYPE html> -->
<html> <html>
<head> <head>

139
console/client/src/sections/console/containers/index.js

@ -570,7 +570,6 @@ function Index (props) {
// //
dispatch(getVideo()).then(res => { dispatch(getVideo()).then(res => {
console.log(res);
if ( if (
res.success res.success
) { ) {
@ -579,67 +578,74 @@ function Index (props) {
const container = document.getElementById('video-play'); const container = document.getElementById('video-play');
console.log(`准备播放`); console.log(`准备播放`);
// 播放方式 1 // 播放方式 1
// const jessibuca = new window.Jessibuca({ const jessibuca = new window.Jessibuca({
// container: container, container: container,
// videoBuffer: 0.2, // 缓存时长 videoBuffer: 0.2, // 缓存时长
// isResize: false, isResize: false,
// text: "", text: "",
// loadingText: "加载中", loadingText: "加载中",
// debug: true, debug: true,
// showBandwidth: false, // 显示网速 showBandwidth: false, // 显示网速
// operateBtns: { showBandwidth: false,
// fullscreen: false, operateBtns: {
// screenshot: false, fullscreen: false,
// play: false, screenshot: false,
// audio: false, play: false,
// }, audio: false,
// forceNoOffscreen: false,
// controlAutoHide: true, fullscreen: true,
// isNotMute: false, screenshot: true,
// }); play: true,
// jessibucas.current = jessibuca audio: true,
// jessibuca.play( },
// `${res.payload.data.ws_flv}` forceNoOffscreen: false,
// ); controlAutoHide: true,
isNotMute: false,
});
jessibucas.current = jessibuca
jessibuca.play(
`${res.payload.data.ws_flv}`
);
// 播放方式 2 // 播放方式 2
const flv = flvjs.createPlayer({ // const flv = flvjs.createPlayer({
type: 'flv', // type: 'flv',
url: `${res.payload.data.ws_flv}`, // url: `${res.payload.data.ws_flv}`,
isLive: true, // isLive: true,
hasAudio: false, // hasAudio: false,
hasVideo: true, // hasVideo: true,
}, { // }, {
enableWorker: false,//分离线程 // enableWorker: false,//分离线程
enalleStashBuffer: false, //IO隐藏缓冲区 // enalleStashBuffer: false, //IO隐藏缓冲区
stashInitialSize: 128, // stashInitialSize: 128,
isLive: true, // isLive: true,
lazyLoad: false, // lazyLoad: false,
// lazyLoadMaxDuration: 3 * 60, // // lazyLoadMaxDuration: 3 * 60,
lazyLoadMaxDuration: 1, // lazyLoadMaxDuration: 1,
seekType: 'range', // seekType: 'range',
autoCleanupSourceBuffer: true, // autoCleanupSourceBuffer: true,
// cors: true, // // cors: true,
// stashInitialSize: 1024 // // stashInitialSize: 1024
}); // });
flv.attachMediaElement(container); // flv.attachMediaElement(container);
flv.load(); // flv.load();
try { // try {
// 初始化 _remuxer // // 初始化 _remuxer
let controller = flv?._transmuxer?._controller // let controller = flv?._transmuxer?._controller
controller._remuxer = { // controller._remuxer = {
flushStashedSamples: function () { // flushStashedSamples: function () {
console.log("flushStashedSamples") // console.log("flushStashedSamples")
} // }
} // }
} catch (error) { // } catch (error) {
console.error(error); // console.error(error);
} // }
flv.play(); // flv.play();
flvPlayer.current = flv // flvPlayer.current = flv
/** 尝试解决播放延迟问题 */
if (flvPlayerInterval) { if (flvPlayerInterval) {
clearInterval(flvPlayerInterval) clearInterval(flvPlayerInterval)
} }
@ -654,8 +660,9 @@ function Index (props) {
// } // }
// } // }
// }, 1000 * 10); // }, 1000 * 10);
/** 尝试 END */
} catch (error) { } catch (error) {
console.error(error);
} }
} }
}) })
@ -708,7 +715,8 @@ function Index (props) {
<canvas ref={xzCvs} id='xzCvs' height={120} width={120} style={{ display: 'none' }}> <canvas ref={xzCvs} id='xzCvs' height={120} width={120} style={{ display: 'none' }}>
您的浏览器不支持canvas,请更换浏览器. 您的浏览器不支持canvas,请更换浏览器.
</canvas> </canvas>
<video {/* video 配合 flvjs 使用 */}
{/* <video
className='card' className='card'
id={'video-play'} id={'video-play'}
autoPlay autoPlay
@ -717,7 +725,16 @@ function Index (props) {
style={{ height: '100%', width: '100%', }} style={{ height: '100%', width: '100%', }}
> >
</video> </video> */}
{/* 这个 div 配合 解析不卡使用 */}
<div
className='card'
id={'video-play'}
style={{ height: '100%', width: '100%', }}
>
</div>
</div> </div>
</Col> </Col>
<Col span={10} style={{ paddingLeft: 8, }}> <Col span={10} style={{ paddingLeft: 8, }}>

Loading…
Cancel
Save