vue-video-player 最新使用教程

首先,非常感謝網(wǎng)絡(luò)各位大神的各種指導(dǎo),學(xué)習(xí)了不少方法

也終于讓我明白了萬事求佛不如求己的道理。。。

完成以下兩步既可以 成功播放m3u8格式---親測(cè)了

  • 安裝
npm install vue-video-player
  • main.js
import VideoPlayer from 'vue-video-player'
import 'video.js/dist/video-js.css'
import 'vue-video-player/src/custom-theme.css'
Vue.use(VideoPlayer)
  • palyer 組件
<template>
  <div class="player-container">
    <video-player :playsinline="true" class="vjs-custom-skin" :options="playerOptions" />
  </div>
</template>

<script>
export default {
  data() {
    return {
      playerOptions: {
        playbackRates: [0.7, 1.0, 1.5, 2.0], // 播放速度
        autoplay: true, // 如果true,瀏覽器準(zhǔn)備好時(shí)開始回放。
        controls: true, // 控制條
        preload: 'auto', // 視頻預(yù)加載
        muted: false, // 默認(rèn)情況下將會(huì)消除任何音頻。
        loop: false, // 導(dǎo)致視頻一結(jié)束就重新開始。
        language: 'zh-CN',
        aspectRatio: '16:9', // 將播放器置于流暢模式,并在計(jì)算播放器的動(dòng)態(tài)大小時(shí)使用該值。值應(yīng)該代表一個(gè)比例 - 用冒號(hào)分隔的兩個(gè)數(shù)字(例如"16:9"或"4:3")
        fluid: true, // 當(dāng)true時(shí),Video.js player將擁有流體大小。換句話說,它將按比例縮放以適應(yīng)其容器。
        sources: [{
          type: 'application/x-mpegURL',
          src: 'http://xxxxx/openUrl/zp7Am0U/live.m3u8'
        }],
        poster: 'http://static.smartisanos.cn/pr/img/video/video_03_cc87ce5bdb.jpg', // 你的封面地址
        // width: document.documentElement.clientWidth,
        notSupportedMessage: '此視頻暫無法播放,請(qǐng)稍后再試' // 允許覆蓋Video.js無法播放媒體源時(shí)顯示的默認(rèn)信息。
      }
    }
  },
  computed: {

  },
  methods: {

  }
}
</script>
<style>
</style>

3.png
  • vue-video-player 也借助了video.js插件,具體配置可參考
  • 視頻type類型 ---video.js源碼
var MimetypesKind = {
  opus: 'video/ogg',
  ogv: 'video/ogg',
  mp4: 'video/mp4',
  mov: 'video/mp4',
  m4v: 'video/mp4',
  mkv: 'video/x-matroska',
  m4a: 'audio/mp4',
  mp3: 'audio/mpeg',
  aac: 'audio/aac',
  caf: 'audio/x-caf',
  flac: 'audio/flac',
  oga: 'audio/ogg',
  wav: 'audio/wav',
  m3u8: 'application/x-mpegURL',
  jpg: 'image/jpeg',
  jpeg: 'image/jpeg',
  gif: 'image/gif',
  png: 'image/png',
  svg: 'image/svg+xml',
  webp: 'image/webp'
};

其他格式的暫未研究

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容