22 lines
607 B
TypeScript
22 lines
607 B
TypeScript
/**
|
|
* 验证浏览器是否支持播放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;
|
|
}
|