赞
踩
npm install vue-video-player@5.0.2
<template> <div> <video id="myVideo" ref="myVideo" controls class="video-js vjs-big-play-centered" style="height:600px; max-height:1000%;max-width:100vw"> <source :src="videoUrl" :type="videoType"> </video> </div> </template> <script> import Video from 'video.js' import 'video.js/dist/video-js.css' import 'videojs-contrib-hls' export default { props:{ url:{ type:String, default:'' } }, data() { return { playHandler: null, // type格式内容 m3u8:application/x-mpegURL,mp4:video/mp4, flv:video/x-flv,mov:rtmp/mp4 videoType:'application/x-mpegURL', videoUrl:'', } }, mounted(){ setTimeout(() => { this.videoUrl = this.url console.log('videoUrl',this.videoUrl) this.initVideo() }, 300) }, computed:{ }, methods:{ async initVideo() { this.$nextTick(() => { this.playHandler = Video('myVideo', { // 确定播放器是否具有用户可以与之交互的控件。没有控件,启动视频播放的唯一方法是使用autoplay属性或通过Player API。 controls: true, // 自动播放属性,muted:静音播放 autoplay: 'muted', // 建议浏览器是否应在<video>加载元素后立即开始下载视频数据。 preload: 'auto', // 设置视频播放器的显示宽度(以像素为单位) width: '887px', // 设置视频播放器的显示高度(以像素为单位) height: '665px' }) }) }, }, } </script> <style scoped> </style>
<template>
<videoPaly :url="videoUrl"/>
</template>
<script>
import videoPaly from '@/components/videoPaly.vue'
export default {
components:{
videoPaly,
},
data(){
return{
videoUrl:'http://playertest.longtailvideo.com/adaptive/bipbop/gear4/prog_index.m3u8',
}
},
}
<video x5-playsinline="true" playsinline="true" webkit-playsinline="true"
id="myVideo" ref="myVideo" controls class="video-js vjs-big-play-centered" style="height:200px;max-width:100vw">
<source
:src="videoUrl"
:type="videoType">
</video>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。