日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 前端技术 > vue >内容正文

vue

vue+video.js实现前端视频流(hls、MP4、flv)

發(fā)布時間:2023/12/2 vue 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 vue+video.js实现前端视频流(hls、MP4、flv) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

前言

之前、寫過關(guān)于西瓜播放器xgplayer可以實(shí)現(xiàn)各種視頻流的前端直播, 目前這篇關(guān)于video.js實(shí)現(xiàn)直播、視頻,拓展下知識面

使用

  • 下載相應(yīng)插件
  • npm install video.js --save npm install videojs-flash --save //rtmp格式 //flv格式 npm install flv.js --save npm install videojs-flvjs-es6 --save //hls格式 video.js7.0以后版本默認(rèn)支持hls(m3u8)格式 可以不安裝,裝了也可以使用 npm install videojs-contrib-hls --save
  • 頁面引入
  • import Videojs from 'video.js'import 'video.js/dist/video-js.css'import "videojs-flvjs-es6";import "videojs-flash";
  • 使用區(qū)別
  • // 標(biāo)簽容器 <videoid="mmiid"class="video-js vjs-big-play-centered vjs-fluid"controlspreload="auto"width="100%"height="100%"> </video> // hls this.videoPlayer = Videojs(document.querySelector('#mmiid'),{autoplay: 'muted',//自動播放controls: true,//用戶可以與之交互的控件loop:true,//視頻一結(jié)束就重新開始muted:false,//默認(rèn)情況下將使所有音頻靜音aspectRatio:"16:9",//顯示比率fullscreen:{options: {navigationUI: 'hide'}},techOrder: ["html5", "flvjs"],// 兼容順序html5:{hls: {withCredentials: true}},sources: [{ src: 'http://ivi.bupt.edu.cn/hls/cctv1hd.m3u8', type: "application/x-mpegURL" }]}) //flv this.videoPlayer = Videojs(document.querySelector('#mmiid'),{autoplay: 'muted',//自動播放controls: true,//用戶可以與之交互的控件loop:true,//視頻一結(jié)束就重新開始muted:false,//默認(rèn)情況下將使所有音頻靜音aspectRatio:"16:9",//顯示比率fullscreen:{options: {navigationUI: 'hide'}},techOrder: ["html5", "flvjs"],// 兼容順序flvjs: {mediaDataSource: {isLive: false,cors: true,withCredentials: false}},sources: [{ src: urlList[0].url, type: "video/x-flv" }]}) // 其他 //rtmp techOrder: ["html5", "flash"],// 兼容順序 sources: [{ src: this.videoUrl, type: "rtmp/flv" }] // mp4 sources: [{ src: this.videoUrl, type: "video/mp4" }]

    測試地址

    HLS直播源地址:

    CCTV1高清:http://ivi.bupt.edu.cn/hls/cctv1hd.m3u8 CCTV3高清:http://ivi.bupt.edu.cn/hls/cctv3hd.m3u8 CCTV6高清:http://ivi.bupt.edu.cn/hls/cctv6hd.m3u8

    RTMP直播源地址:

    香港衛(wèi)視:rtmp://live.hkstv.hk.lxdns.com/live/hks1 rtmp://live.hkstv.hk.lxdns.com/live/hks2 湖南衛(wèi)視:rtmp://58.200.131.2:1935/livetv/hunantv 美國1:rtmp://ns8.indexforce.com/home/mystream 美國中文電視:rtmp://media3.sinovision.net:1935/live/livestream

    FLV視頻:

    http://1011.hlsplay.aodianyun.com/demo/game.flv

    總結(jié)

    以上是生活随笔為你收集整理的vue+video.js实现前端视频流(hls、MP4、flv)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。