-
Notifications
You must be signed in to change notification settings - Fork 0
/
Controls.vue
72 lines (67 loc) · 1.67 KB
/
Controls.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
<template>
<div class="Controls">
<button class="Controls-button" @click="previousMedia" :disabled="isFirstMedia">{{ previousMediaLabel }}</button>
<button class="Controls-button" @click="nextMedia" :disabled="isLastMedia">{{ nextMediaLabel }}</button>
</div>
</template>
<script>
export default {
name: 'Controls',
props: {
eventBus: {
required: true,
type: Object
},
previousMediaLabel: {
required: false,
type: String,
default: 'Précédent'
},
nextMediaLabel: {
required: false,
type: String,
default: 'Suivant'
},
originIsLastMedia: {
required: false,
type: Boolean,
default: false
}
},
data() {
return {
isFirstMedia: true,
isLastMedia: false
}
},
methods: {
previousMedia() {
this.eventBus.$emit('Controls::PreviousMedia')
},
nextMedia() {
this.eventBus.$emit('Controls::NextMedia')
}
},
mounted() {
this.isLastMedia = this.originIsLastMedia
// Reset controls buttons on media update
this.eventBus.$on('Player::UpdateMedia', () => {
this.isFirstMedia = false
this.isLastMedia = false
})
// Disable prev button if current media is first
this.eventBus.$on('Player::IsFirstMedia', () => {
this.isFirstMedia = true
})
// Disable next button if current media is last
this.eventBus.$on('Player::IsLastMedia', () => {
this.isLastMedia = true
})
},
}
</script>
<style lang="scss" scoped>
.Controls-button[disabled] {
cursor: initial;
}
</style>