| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- /**
- * Jessibuca 播放器配置
- */
- export const getJessibucaConfig = (container) => {
- return {
- container, // 播放器容器
- videoBuffer: 0.5, // 视频缓冲区时长,单位:秒
- audioBuffer: 0.5, // 音频缓冲区时长,单位:秒
- debug: true, // 是否开启调试模式
- forceNoOffscreen: true, // 是否强制不使用离屏模式
- isResize: true, // 是否根据容器自动调整大小
- isFullResize: false, // 是否全屏模式调整大小
- text: '视频加载中...', // 加载过程中的提示文本
- loadingText: '加载中...',
- background: '#000000', // 背景色
- controlAutoHide: false, // 控制栏是否自动隐藏
- showBandwidth: true, // 是否显示网速
- operateBtns: {
- fullscreen: true, // 是否显示全屏按钮
- screenshot: true, // 是否显示截图按钮
- play: true, // 是否显示播放按钮
- audio: true, // 是否显示声音按钮
- recording: false // 是否显示录制按钮
- },
- supportDblclickFullscreen: true, // 是否支持双击全屏
- showBandwidthPosition: 'controls', // 显示网速的位置
- keepScreenOn: true, // 是否保持屏幕常亮
- hotKey: true, // 是否支持热键
- loadingTimeout: 10, // 视频加载超时时间,单位:秒
- // 指定解码器文件路径
- decoder: process.env.BASE_URL + 'decoder.js',
- wasmUrl: process.env.BASE_URL + 'decoder.wasm',
-
- // 解码配置
- decoderConfig: {
- // 解码类型,可选值:'software', 'hardware'
- type: 'auto',
- // 是否优先使用 WASM 解码
- preferWasm: true,
- // 是否使用 Worker 进行解码
- useWorker: true,
- // 是否使用 SIMD 加速
- useSIMD: true,
- // 是否使用 WebGL 渲染
- useWebGL: true,
- },
-
- // 视频渲染配置
- render: {
- // 是否开启抗锯齿
- antialias: true,
- // 是否使用 WebGL2
- useWebGL2: true,
- // 是否使用 YUV 渲染
- yuv: true,
- },
-
- // 网络配置
- network: {
- // 是否开启 HTTP 请求超时
- timeout: 10000,
- // 是否开启重试
- retry: true,
- // 重试次数
- retryCount: 3,
- // 重试间隔,单位:毫秒
- retryDelay: 1000,
- }
- };
- };
- /**
- * 根据视频格式获取 Jessibuca 播放地址
- * @param {string} url - 原始 URL
- * @param {string} format - 视频格式
- * @returns {string} - 处理后的 URL
- */
- export const getJessibucaUrl = (url, format) => {
- // 对于 WebSocket 格式,确保 URL 以 ws:// 或 wss:// 开头
- if (format === 'ws' && !url.startsWith('ws://') && !url.startsWith('wss://')) {
- return `ws://${url.replace(/^https?:\/\//, '')}`;
- }
-
- // 对于 FLV 格式,确保 URL 正确
- if (format === 'flv' && !url.includes('.flv') && !url.includes('?') && !url.includes('=')) {
- // 如果 URL 不包含 .flv 后缀且没有查询参数,尝试添加 .flv 后缀
- return `${url}.flv`;
- }
-
- // 对于 HLS/M3U8 格式,确保 URL 正确
- if ((format === 'hls' || format === 'm3u8') && !url.includes('.m3u8') && !url.includes('?') && !url.includes('=')) {
- // 如果 URL 不包含 .m3u8 后缀且没有查询参数,尝试添加 .m3u8 后缀
- return `${url}.m3u8`;
- }
-
- return url;
- };
|