html5 h265播放器,PC端播放H265

说明

需要在PC端浏览器(Chrome)中播放直播视频,视频格式有H264/H265。有不少三方库可以实现。

通过video.js(支持H264,不支持H265)

videojs-contrib-hls embed

Video.js Example Embed

data-setup='{}'>

参考地址:

通过hls.js(支持H264,不支持H265)

pc play m3u8(hlsjs)

video {

width: 600px;

height: auto;

}

pc play m3u8(hlsjs)

var video = document.getElementById('video');

var videoSrc = 'http://ivi.bupt.edu.cn/hls/cctv1hd.m3u8';

if (Hls.isSupported()) {

var hls = new Hls();

hls.loadSource(videoSrc);

hls.attachMedia(video);

hls.on(Hls.Events.MANIFEST_PARSED, function () {

video.play();

});

}

// hls.js is not supported on platforms that do not have Media Source

// Extensions (MSE) enabled.

//

// When the browser has built-in HLS support (check using `canPlayType`),

// we can provide an HLS manifest (i.e. .m3u8 URL) directly to the video

// element through the `src` property. This is using the built-in support

// of the plain video element, without using hls.js.

//

// Note: it would be more normal to wait on the 'canplay' event below however

// on Safari (where you are most likely to find built-in HLS support) the

你可能感兴趣的:(html5,h265播放器)