首先,非常感謝網(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'
};