视频播放同时支持h265和h264播放
This commit is contained in:
21
apps/web-antd/src/utils/video.ts
Normal file
21
apps/web-antd/src/utils/video.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* 验证浏览器是否支持播放h265 编码的视频流
|
||||
*/
|
||||
export function checkHEVCSupport() {
|
||||
const video = document.createElement('video');
|
||||
const h265Support = {
|
||||
hevc: false,
|
||||
hvc1: false,
|
||||
};
|
||||
|
||||
// 测试不同的HEVC MIME类型
|
||||
if (video.canPlayType) {
|
||||
h265Support.hevc =
|
||||
video.canPlayType('video/mp4; codecs="hev1.1.6.L93.B0"') !== '';
|
||||
h265Support.hvc1 =
|
||||
video.canPlayType('video/mp4; codecs="hvc1.1.6.L93.B0"') !== '';
|
||||
}
|
||||
const result = h265Support.hevc || h265Support.hvc1;
|
||||
console.log('当前浏览器是否支持h265:' + result);
|
||||
return result;
|
||||
}
|
Reference in New Issue
Block a user