-
Notifications
You must be signed in to change notification settings - Fork 0
/
Autoplay.vue
67 lines (65 loc) · 1.62 KB
/
Autoplay.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
<template>
<div class="KaliopPlayer-autoplay">
<span class="KaliopPlayer-autoplayTitle">{{ autoplayTitle }}</span>
<div class="KaliopPlayer-autoplayCounter"><span>{{ currentMedia }}</span>/<span>{{ mediasLength }}</span></div>
<div class="KaliopPlayer-autoplayToggle">
<label for="kaliopplayer-autoplay">
<input type="checkbox" name="kaliopplayer-autoplay" id="kaliopplayer-autoplay" v-model="autoplay">
{{ autoplayLabel }}
<span></span>
</label>
</div>
</div>
</template>
<script>
export default {
name: 'Autoplay',
props: {
eventBus: {
required: true,
type: Object
},
mediasLength: {
required: true,
type: Number
},
originAutoplay: {
required: false,
type: Boolean,
default: false
},
autoplayTitle: {
required: false,
type: String,
default: 'Vidéos à suivre'
},
autoplayLabel: {
required: false,
type: String,
default: 'Lecture automatique'
}
},
data() {
return {
currentMedia: 1,
autoplay: false
}
},
methods: {
// Call when updating autoplay value to notify media player
autoplayUpdate(val, oldVal) {
this.eventBus.$emit('Autoplay::AutoplayState', val)
}
},
watch: {
autoplay: 'autoplayUpdate'
},
mounted() {
this.autoplay = this.originAutoplay
// Update current media index
this.eventBus.$on('Player::UpdateMedia', ({ index } = payload) => {
this.currentMedia = index + 1
})
},
}
</script>