vue-video-player視頻播放器使用配置詳解
本文實(shí)例為大家分享了vue-video-player視頻播放器的使用配置,供大家參考,具體內(nèi)容如下
1、安裝
npm install vue-video-player -save
2、在main.js中添加
import VueVideoPlayer from ’vue-video-player’ // 視頻播放器import ’video.js/dist/video-js.css’Vue.use(VueVideoPlayer)
3、新建一個(gè)vueVideoPlayer.vue組件供調(diào)用
<template> <div id='vueVideoPlayer'> <video-player ref='videoPlayer' :playsinline='true' :options='playerOptions'></video-player> </div></template><script>export default { name: ’vueVideoPlayer’, props: { src: { type: String }, cover_url: { type: String } }, data () { return { // 配置信息 playerOptions: { playbackRates: [0.7, 1.0, 1.5, 2.0], // 播放速度 autoplay: false, // 如果true,瀏覽器準(zhǔn)備好時(shí)開始回放。 muted: false, // 默認(rèn)情況下將會(huì)消除任何音頻。 loop: false, // 導(dǎo)致視頻一結(jié)束就重新開始。 preload: ’auto’, // 建議瀏覽器在<video>加載元素后是否應(yīng)該開始下載視頻數(shù)據(jù)。auto瀏覽器選擇最佳行為,立即開始加載視頻(如果瀏覽器支持) language: ’zh-CN’, aspectRatio: ’16:10’, // 將播放器置于流暢模式,并在計(jì)算播放器的動(dòng)態(tài)大小時(shí)使用該值。值應(yīng)該代表一個(gè)比例 - 用冒號分隔的兩個(gè)數(shù)字(例如'16:9'或'4:3') fluid: true, // 當(dāng)true時(shí),Video.js player將擁有流體大小。換句話說,它將按比例縮放以適應(yīng)其容器。 sources: [{ src: this.src, // 路徑 type: ’video/mp4’ // 類型 }], poster: this.cover_url, // 你的封面地址 // width: document.documentElement.clientWidth, notSupportedMessage: ’此視頻暫無法播放,請稍后再試’, // 允許覆蓋Video.js無法播放媒體源時(shí)顯示的默認(rèn)信息。 controlBar: { timeDivider: true, durationDisplay: true, remainingTimeDisplay: false, fullscreenToggle: true // 全屏按鈕 } } } }}
4、在其他組件調(diào)用
<vueVideoPlayer :src='http://m.4tl426be.cn/bcjs/data.url' :cover_url='data.cover_url' />import vueVideoPlayer from ’./module/vueVideoPlayer’// 不要忘記注冊components: { vueVideoPlayer }
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. Warning: require(): open_basedir restriction in effect,目錄配置open_basedir報(bào)錯(cuò)問題分析2. ASP.NET Core 5.0中的Host.CreateDefaultBuilder執(zhí)行過程解析3. ASP調(diào)用WebService轉(zhuǎn)化成JSON數(shù)據(jù),附j(luò)son.min.asp4. SharePoint Server 2019新特性介紹5. ASP中常用的22個(gè)FSO文件操作函數(shù)整理6. React+umi+typeScript創(chuàng)建項(xiàng)目的過程7. php網(wǎng)絡(luò)安全中命令執(zhí)行漏洞的產(chǎn)生及本質(zhì)探究8. 無線標(biāo)記語言(WML)基礎(chǔ)之WMLScript 基礎(chǔ)第1/2頁9. 三個(gè)不常見的 HTML5 實(shí)用新特性簡介10. php測試程序運(yùn)行速度和頁面執(zhí)行速度的代碼
