@mixd-id/web-scaffold 0.1.230406213 → 0.1.230406214
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div :class="$style.comp" :style="computedStyle">
|
|
3
|
-
<
|
|
4
|
-
:src="videoUrl"
|
|
5
|
-
frameborder="0"
|
|
6
|
-
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
|
|
7
|
-
allowfullscreen />
|
|
8
|
-
<div v-else :class="videoClass" class="relative" @click="start = true">
|
|
3
|
+
<div id="player" :class="videoClass" class="relative" @click="loadVideo">
|
|
9
4
|
<Image :src="thumbnailUrl" :class="videoClass" />
|
|
10
5
|
<div class="absolute top-0 left-0 right-0 bottom-0 flex items-center justify-center">
|
|
11
6
|
<div class="bg-primary-500 cursor-pointer hover:bg-primary-600 p-3 px-4 rounded-lg">
|
|
@@ -20,8 +15,11 @@
|
|
|
20
15
|
|
|
21
16
|
import { componentMixin } from '../mixin/component'
|
|
22
17
|
|
|
18
|
+
|
|
23
19
|
export default{
|
|
24
20
|
|
|
21
|
+
inject: [ 'alert' ],
|
|
22
|
+
|
|
25
23
|
mixins: [ componentMixin ],
|
|
26
24
|
|
|
27
25
|
props: {
|
|
@@ -52,8 +50,51 @@ export default{
|
|
|
52
50
|
|
|
53
51
|
},
|
|
54
52
|
|
|
53
|
+
methods: {
|
|
54
|
+
|
|
55
|
+
loadVideo(){
|
|
56
|
+
|
|
57
|
+
if(!('YT' in window)){
|
|
58
|
+
const script = document.createElement('script')
|
|
59
|
+
script.src = 'https://www.youtube.com/iframe_api'
|
|
60
|
+
document.head.appendChild(script)
|
|
61
|
+
}
|
|
62
|
+
else{
|
|
63
|
+
|
|
64
|
+
if(!this.player){
|
|
65
|
+
this.player = new YT.Player('player', {
|
|
66
|
+
videoId: this.videoId,
|
|
67
|
+
playerVars: {
|
|
68
|
+
autoplay: 1,
|
|
69
|
+
controls: 0,
|
|
70
|
+
rel: 0,
|
|
71
|
+
},
|
|
72
|
+
events: {
|
|
73
|
+
onReady: () => console.log('onReady'),
|
|
74
|
+
onStateChange: () => console.log('onStateChange'),
|
|
75
|
+
onAutoplayBlocked: () => this.alert('onAutoplayBlocked'),
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
else{
|
|
80
|
+
this.player.loadVideoById(this.videoId)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
mounted() {
|
|
88
|
+
this.id = this.uniqid()
|
|
89
|
+
window.onYouTubeIframeAPIReady = () => {
|
|
90
|
+
this.loadVideo()
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
|
|
55
94
|
data(){
|
|
56
95
|
return {
|
|
96
|
+
id: null,
|
|
97
|
+
player: null,
|
|
57
98
|
start: false
|
|
58
99
|
}
|
|
59
100
|
}
|