m3u8
学习地址: http://www.cnblogs.com/afrog/p/6689179.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link href="https://cdn.bootcss.com/video.js/6.2.8/alt/video-js-cdn.min.css" rel="stylesheet">
</head>
<body>
<video id="video" class="video-js vjs-default-skin" controls>
<source
src="xxxxxxx.m3u8" //视频源
type="application/x-mpegURL">
</video>
<script src="https://cdn.bootcss.com/video.js/6.2.8/video. .js"></script>
<script src="https://cdn.bootcss.com/videojs-contrib-hls/5.10.1/videojs-contrib-hls.min.js"></script>
<script>
var player = videojs('video');
player.play();
</script>
</body>
</html>
flv
<script src="https://cdn.bootcss.com/flv.js/1.3.2/flv.min.js"></script>
<video id="video" ></video>
play(){
var that=this;
console.log(this.isPlay)
if(!flvjs.isSupported()){
that.paly=function () {
Toast({
message: "您的设备不支持flv播放",
className: "toast",
position: 'bottom',
duration: 1000
});
}
return that.paly()
}
this.isPlay=true;
var video = document.getElementById('video');
var flvPlayer = flvjs.createPlayer({
type: 'flv',
url:xxx.flv, //视频源
});
flvPlayer.attachMediaElement(video);
flvPlayer.load();
flvPlayer.play();
that.play=function () {
if(that.isPlay){
video.pause()
that.isPlay=false;
return
}
video.play();
that.isPlay=true
}
},
网友评论