我是靠谱客的博主 现代宝马,这篇文章主要介绍vue插入音频视频,现在分享给大家,希望可以做个参考。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
方法一:iframe插入视频链接 1.1 ##### 当前播放的视频 <div class="video-wrap" style="width:80%;float:left;oveflow:hidden;"> <iframe :src="this.activeVideo.youtobeURL" frameborder='0' allow='autoplay;encrypted-media' allowfullscreen style='width:100%;height:500px;'> </iframe> <h3>{{this.activeVideo.title}}</h3> </div> 1.2#####视频列表 <div class="video-list" style="float:right;width:20%;text-align:center;"> <div v-for='video in videos' :key='video.id' class="thumbnail" > <div class="thumbnail-img" > <div style="height:50%;width:100%;position:absolute;z-index:999" @click="activeVideoShow(video.id)"></div> <iframe :src='video.youtobeURL' :alt="video.title" /> </div> <div class="thumbnail-info"> <h4>{{video.title}}</h4> <div class="thumbnail-views"> <span>{{video.speaker}}</span> <span>{{video.views}} Views</span> </div> <div class="thumbnail-describe"> {{video.describe}} </div> </div> </div> </div> 1.3#####定义的数据结构(自己写的demo,可能实际中后台返的数据结构会有所不同) import videojs from 'video.js' --------------------------------- props:{ options:{ type:Object, default(){ return{ } } } }, data(){ return{ player:null } }, mounted(){ this.player=videojs(this.$refs.videoPlayer,this.options,function onPlayerReady(){ console.log('onPlayerReady',this) }) } 2.2#####在插入视频的页面中引入上面的videoPlayer组件,在view层代码如下: <video-player class="video-player vjs-custom-skin " ref="videoPlayer" :playsinline='false' :options='videoOptions' @play="onPlayerPlay($event)" @pause='onPlayerPause($event)' @statechagned='playerStateChanged($event)' > </video-player> 2.3#####需要引入的插件 import './../../node_modules/video.js/dist/video-js.css' import './../../node_modules/vue-video-player/src/custom-theme.css' import videojs from 'video.js' import {videoPlayer} from 'vue-video-player' import 'videojs-flash' import VideoPlayer from '@/components/videoPlayer.vue' 2.3-1#####定义相关数据 props:{ state:Boolean, }, data(){ return{ videoOptions:{ playbackRates:[1.0,1.5,2.0], // 播放速度 autoplay:false, // 如果true,浏览器准备好时开始回放 controls:true, muted:false, // 默认情况下将会消除任何音频 loop:false, //循环播放 preload:'auto', // <video>加载元素后立即加载视频 language:'zh-CN', aspectRatio:'16:9', //流畅模式,并计算播放器动态大小时使用该值 fluid:true, //按比例缩放以适应容器 sources:[{ src:'http://vjs.zencdn.net/v/oceans.mp4', type:'video/mp4' }], poster:'http://vjs.zencdn.net/v/oceans.png', // 封面地址 notSupportedMessage:'此视频暂无法播放,请稍后再试', } } } 代码地址: https://github.com/yinglichen/videoPlayer

最后

以上就是现代宝马最近收集整理的关于vue插入音频视频的全部内容,更多相关vue插入音频视频内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(61)

评论列表共有 0 条评论

立即
投稿
返回
顶部