视频播放同时支持h265和h264播放

This commit is contained in:
15683799673
2025-08-10 19:35:45 +08:00
parent c3f43f6e71
commit 489ec29184
5 changed files with 104 additions and 91 deletions

View 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;
}