vue-video-player視頻播放器使用配置詳解
本文實例為大家分享了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、新建一個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,瀏覽器準備好時開始回放。 muted: false, // 默認情況下將會消除任何音頻。 loop: false, // 導(dǎo)致視頻一結(jié)束就重新開始。 preload: ’auto’, // 建議瀏覽器在<video>加載元素后是否應(yīng)該開始下載視頻數(shù)據(jù)。auto瀏覽器選擇最佳行為,立即開始加載視頻(如果瀏覽器支持) language: ’zh-CN’, aspectRatio: ’16:10’, // 將播放器置于流暢模式,并在計算播放器的動態(tài)大小時使用該值。值應(yīng)該代表一個比例 - 用冒號分隔的兩個數(shù)字(例如'16:9'或'4:3') fluid: true, // 當true時,Video.js player將擁有流體大小。換句話說,它將按比例縮放以適應(yīng)其容器。 sources: [{ src: this.src, // 路徑 type: ’video/mp4’ // 類型 }], poster: this.cover_url, // 你的封面地址 // width: document.documentElement.clientWidth, notSupportedMessage: ’此視頻暫無法播放,請稍后再試’, // 允許覆蓋Video.js無法播放媒體源時顯示的默認信息。 controlBar: { timeDivider: true, durationDisplay: true, remainingTimeDisplay: false, fullscreenToggle: true // 全屏按鈕 } } } }}
4、在其他組件調(diào)用
<vueVideoPlayer :src='http://www.gepszalag.com/bcjs/data.url' :cover_url='data.cover_url' />import vueVideoPlayer from ’./module/vueVideoPlayer’// 不要忘記注冊components: { vueVideoPlayer }
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. jsp網(wǎng)頁實現(xiàn)貪吃蛇小游戲2. SpringMVC+Jquery實現(xiàn)Ajax功能3. HTML5 Canvas繪制圖形從入門到精通4. JavaScript實現(xiàn)組件化和模塊化方法詳解5. .Net Core和RabbitMQ限制循環(huán)消費的方法6. ASP.NET MVC遍歷驗證ModelState的錯誤信息7. 淺談SpringMVC jsp前臺獲取參數(shù)的方式 EL表達式8. 刪除docker里建立容器的操作方法9. jsp+servlet簡單實現(xiàn)上傳文件功能(保存目錄改進)10. ASP中if語句、select 、while循環(huán)的使用方法
