vue 视频播放(使用vue-video-player)
安装
npm i vue-video-player -S
引入
import { videoPlayer } from 'vue-video-player'
import 'video.js/dist/video-js.css'
import 'vue-video-player/src/custom-theme.css'
使用
<template>
<div class="container">
<video-player
class="video-player vjs-custom-skin"
ref="videoPlayer"
:playsinline="true"
:options="playerOptions"
></video-player>
</div>
</template>
<script>
import { videoPlayer } from 'vue-video-player'
import 'video.js/dist/video-js.css'
import 'vue-video-player/src/custom-theme.css'
export default {
name: 'index',
components: { videoPlayer },
data() {
return {
playerOptions: {
playbackRates: [0.7, 1.0, 1.25, 1.5, 2.0],
autoplay: false,
muted: false,
loop: false,
preload: 'auto',
language: 'zh-CN',
aspectRatio: '16:9',
fluid: true,
sources: [
{
type: 'video/mp4',
src: 'http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4',
},
],
poster: '',
notSupportedMessage: '此视频暂无法播放,请稍后再试',
controlBar: {
timeDivider: true,
durationDisplay: true,
remainingTimeDisplay: false,
fullscreenToggle: true,
},
},
}
},
methods: {},
}
</script>