常见的H5直播格式及解析

2017-09-05  本文已影响0人  小小一小只

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
        }
 },
上一篇 下一篇

猜你喜欢

热点阅读