inleft
2022-08-23 eeef9f3413151bea79690aac4abb737aff0cb6c8
commit | author | age
105729 1 <style lang="less" scoped>
I 2     .videoBoxList {
3         display: flex;
4         // justify-content: space-evenly;
5         flex-wrap: wrap;
6         // align-content:flex-start;
7         min-height: 700px;
8         align-items: stretch;
9     }
10
11     .myVideo {
12         position: relative;
13         // width: 220px;
14         // height: 140px;
15         width: 300px;
16         height: 180px;
17         background-color: #565656;
18         border-radius: 10px;
19         margin: 10px;
20         display: flex;
21
22         .face {
23             z-index: 1;
24         }
25
26         img {
27             max-width: 100%;
28         }
29     }
30
31
32     .myVideo:hover {
33         .mark {
34             background-color: #000;
35             display: initial;
36         }
37
38         .player-video-state {
39             // display: initial;
40         }
41     }
42
43
44
45
46     .dplayer {
47         width: 500px;
48     }
49
50     .mark {
51         opacity: 0.45;
52         width: 100%;
53         height: 100%;
54         position: absolute;
55         display: none;
56     }
57
58     .player-video-state {
59         // position: absolute;
60         left: 43%;
61         top: 35%;
62         width: 50px;
63         height: 50px;
64         display: none;
65     }
66 </style>
67
68 <template>
69     <div>
70         <div class="videoBoxList">
71             <div class="myVideo" v-for=" (temp,index) in ['test1','test2','test3','test4','test5']">
72                 <div :id="temp" :ref="temp" class="dplayer"></div>
73                 <!-- <div class="mark" ></div> -->
74                 <!-- <img src="qq.png"> -->
75                 <!-- 视频 -->
76                 <div class="player-video-state">
77                     <span class="bp-svgicon">
78                         <svg viewBox="0 0 80 80" xmlns="http://www.w3.org/2000/svg"
79                             xmlns:xlink="http://www.w3.org/1999/xlink">
80                             <defs>
81                                 <path id="pid-1-svgo-a" d="M0 0h80v80H0z"></path>
82                                 <path
83                                     d="M52.546 8.014a3.998 3.998 0 014.222 3.077c.104.446.093.808.039 1.138a2.74 2.74 0 01-.312.881c-.073.132-.16.254-.246.376l-.257.366-.521.73c-.7.969-1.415 1.926-2.154 2.866l-.015.02a240.945 240.945 0 015.986.341l1.643.123.822.066.41.034.206.018.103.008.115.012c1.266.116 2.516.45 3.677.975a11.663 11.663 0 013.166 2.114c.931.87 1.719 1.895 2.321 3.022a11.595 11.595 0 011.224 3.613c.03.157.046.316.068.474l.015.119.013.112.022.206.085.822.159 1.646c.1 1.098.19 2.198.27 3.298.315 4.4.463 8.829.36 13.255a166.489 166.489 0 01-.843 13.213c-.012.127-.034.297-.053.454a7.589 7.589 0 01-.072.475l-.04.237-.05.236a11.762 11.762 0 01-.74 2.287 11.755 11.755 0 01-5.118 5.57 11.705 11.705 0 01-3.623 1.263c-.158.024-.316.052-.475.072l-.477.053-.821.071-1.644.134c-1.096.086-2.192.16-3.288.23a260.08 260.08 0 01-6.578.325c-8.772.324-17.546.22-26.313-.302a242.458 242.458 0 01-3.287-.22l-1.643-.129-.822-.069-.41-.035-.206-.018c-.068-.006-.133-.01-.218-.02a11.566 11.566 0 01-3.7-.992 11.732 11.732 0 01-5.497-5.178 11.73 11.73 0 01-1.215-3.627c-.024-.158-.051-.316-.067-.475l-.026-.238-.013-.119-.01-.103-.07-.823-.132-1.648a190.637 190.637 0 01-.22-3.298c-.256-4.399-.358-8.817-.258-13.233.099-4.412.372-8.811.788-13.197a11.65 11.65 0 013.039-6.835 11.585 11.585 0 016.572-3.563c.157-.023.312-.051.47-.07l.47-.05.82-.07 1.643-.13a228.493 228.493 0 016.647-.405l-.041-.05a88.145 88.145 0 01-2.154-2.867l-.52-.73-.258-.366c-.086-.122-.173-.244-.246-.376a2.74 2.74 0 01-.312-.881 2.808 2.808 0 01.04-1.138 3.998 3.998 0 014.22-3.077 2.8 2.8 0 011.093.313c.294.155.538.347.742.568.102.11.19.23.28.35l.27.359.532.72a88.059 88.059 0 012.06 2.936 73.036 73.036 0 011.929 3.03c.187.313.373.628.556.945 2.724-.047 5.447-.056 8.17-.038.748.006 1.496.015 2.244.026.18-.313.364-.624.549-.934a73.281 73.281 0 011.93-3.03 88.737 88.737 0 012.059-2.935l.533-.72.268-.359c.09-.12.179-.24.281-.35a2.8 2.8 0 011.834-.881zM30.13 34.631a4 4 0 00-.418 1.42 91.157 91.157 0 00-.446 9.128c0 2.828.121 5.656.364 8.483l.11 1.212a4 4 0 005.858 3.143c2.82-1.498 5.55-3.033 8.193-4.606a177.41 177.41 0 005.896-3.666l1.434-.942a4 4 0 00.047-6.632 137.703 137.703 0 00-7.377-4.708 146.88 146.88 0 00-6.879-3.849l-1.4-.725a4 4 0 00-5.382 1.742z"
84                                     id="pid-1-svgo-d"></path>
85                                 <filter x="-15.4%" y="-16.3%" width="130.9%" height="132.5%"
86                                     filterUnits="objectBoundingBox" id="pid-1-svgo-c">
87                                     <feOffset dy="2" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset>
88                                     <feGaussianBlur stdDeviation="1" in="shadowOffsetOuter1" result="shadowBlurOuter1">
89                                     </feGaussianBlur>
90                                     <feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0"
91                                         in="shadowBlurOuter1" result="shadowMatrixOuter1"></feColorMatrix>
92                                     <feOffset in="SourceAlpha" result="shadowOffsetOuter2"></feOffset>
93                                     <feGaussianBlur stdDeviation="3.5" in="shadowOffsetOuter2"
94                                         result="shadowBlurOuter2">
95                                     </feGaussianBlur>
96                                     <feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"
97                                         in="shadowBlurOuter2" result="shadowMatrixOuter2"></feColorMatrix>
98                                     <feMerge>
99                                         <feMergeNode in="shadowMatrixOuter1"></feMergeNode>
100                                         <feMergeNode in="shadowMatrixOuter2"></feMergeNode>
101                                     </feMerge>
102                                 </filter>
103                             </defs>
104                             <g fill="none" fill-rule="evenodd" opacity=".8">
105                                 <mask id="pid-1-svgo-b" fill="#fff">
106                                     <use xlink:href="#pid-1-svgo-a"></use>
107                                 </mask>
108                                 <g mask="url(#pid-1-svgo-b)">
109                                     <use fill="#000" filter="url(#pid-1-svgo-c)" xlink:href="#pid-1-svgo-d"></use>
110                                     <use fill="#FFF" xlink:href="#pid-1-svgo-d"></use>
111                                 </g>
112                             </g>
113                         </svg>
114                     </span>
115                 </div>
116             </div>
117         </div>
118     </div>
119 </template>
120
121 <script>
122     import Hls from 'hls.js'
123     import DPlayer from 'dplayer'
124
125     export default {
126         data() {
127             return {
128                 dp: null,
129                 video: {},
130                 video1: {},
131                 video2: {},
132             }
133         },
134         methods: {
135             myPlay() {
136                 this.$message.info("start play..")
137             },
138             loadVideo(videoInfo, index) {
139                 this.dp = new DPlayer({
140                     element: document.getElementById(index),
141                     //logo: "https://qczh-1252727916.cos.ap-nanjing.myqcloud.com/pic/273658f508d04d488414fd2b84c9f923.png", // 在视频左上角上打一个logo
142                     // hotkey: true, // 是否支持热键,调节音量,播放,暂停等
143                     mutex: false, //  防止同时播放多个用户,在该用户开始播放时暂停其他用户
144                     theme: "#b7daff", // 风格颜色,例如播放条,音量条的颜色
145                     loop: false, // 是否自动循环
146                     lang: "zh-cn", // 语言,'en', 'zh-cn', 'zh-tw'
147                     // screenshot: true, // 是否允许截图(按钮),点击可以自动将截图下载到本地
148                     preload: "auto", // 自动预加载
149                     volume: 0.1, // 初始化音量
150                     playbackSpeed: [2, 1, 0.5], //可选的播放速度,可自定义
151                     contextmenu: [
152                         //  自定义上下文菜单
153                         // 右键菜单
154                         {
155                             text: "b站",
156                             link: "https://www.bilibili.com"
157                         },
158                         {
159                             text: "选项二",
160                             click: player => {
161                                 console.log(player);
162                             }
163                         }
164                     ],
165                     highlight: [
166                         //进度条上的自定义时间标记
167                         // 进度条时间点高亮
168                         {
169                             text: "10M",
170                             time: 60
171                         },
172                         {
173                             text: "20M",
174                             time: 120
175                         }
176                     ],
177                     video: {
178                         pic: videoInfo.img, // 视频封面
179                         url: videoInfo.url,
180                         type: videoInfo.type,
181                         customType: {
182                             customHls: function(video, player) {
183                                 const hls = new Hls()
184                                 hls.loadSource(video.src)
185                                 hls.attachMedia(video)
186                             }
187                         }
188                     }
189                 })
190             }
191         },
192         mounted() {
193             this.video1 = {
194                 img: "http://t.inleft.com/share/media_photo/faye_video.png",
195                 url: "http://t.inleft.com/share/myVideo/faye/faye.m3u8",
196                 type: "customHls"
197             }
198             this.video2 = {
199                 img: "http://t.inleft.com/share/media_photo/idea_beijing.jpg",
200                 url: "http://t.inleft.com/share/myVideo/canon/canon.m3u8",
201                 type: "customHls"
202             }
203             this.video3 = {
204                 img: "http://t.inleft.com/share/media_photo/idea_beijing.jpg",
205                 url: "http://t.inleft.com/share/mp3/EOPMusic%283%29.mp3",
206                 type: "normal"
207             }
208             this.video4 = {
209                 img: "http://t.inleft.com/share/media_photo/idea_beijing.jpg",
210                 url: "http://t.inleft.com/share/mp3/EOPMusic%284%29.mp3",
211                 type: "normal"
212             }
213             this.video5 = {
214                 img: "http://t.inleft.com/share/media_photo/idea_beijing.jpg",
215                 url: "http://t.inleft.com/share/mp3/EOPMusic%282%29.mp3",
216                 type: "normal"
217             }
218
219             // getVideo: ajax request for getting videoInfo
220             /*   getVideo().then(res => {
221                 this.video = res.data.video
222                 this.laodVideo(this.video)
223               }) */
224             this.video = {
225                 //封面
226                 //img: "https://cn.bing.com/th?id=OHR.MeotoIwa_ZH-CN3126370410_1920x1080.jpg&rf=LaDigue_1920x1080.jpg",
227                 img: "http://t.inleft.com/share/media_photo/idea_beijing.jpg",
228                 // video: "https://vod3.bdzybf3.com/20210509/ZMHA3RpS/1000kb/hls/index.m3u8",
229                 // video: "http://t.inleft.com/share/ckplayer/ckplayer-master/sample/test/video_tieba.m3u8",
230                 // video: videoUrl,
231                 // video: "http://t.inleft.com/share/mp3/inleft-test-20211103-rainbow.mp3",
232             }
233             this.loadVideo(this.video1, "test1")
234             this.loadVideo(this.video2, "test2")
235             this.loadVideo(this.video3, "test3")
236             this.loadVideo(this.video4, "test4")
237             this.loadVideo(this.video5, "test5")
238
239             // 以下为隐藏一些作者的信息和视频播放源 如不需要可删除
240             // document.querySelector(".dplayer-menu").remove(); //隐藏右键菜单
241             document.querySelector(".dplayer-mask").remove();
242             document.querySelector(".dplayer-info-panel-item-url").remove(); //隐藏播放源
243             let length = document.querySelectorAll(".dplayer-menu-item").length;
244             document.querySelectorAll(".dplayer-menu-item")[length - 2].remove(); // 去掉作者信息
245             document.querySelectorAll(".dplayer-menu-item")[length - 1].remove(); // 去掉作者信息
246         }
247     }
248 </script>