2021-09-04 12:31:00 -05:00
|
|
|
|
<template>
|
2022-06-06 17:19:02 -05:00
|
|
|
|
<modals-modal v-model="show" @input="modalInput" :width="200" height="100%">
|
2021-11-02 19:44:42 -05:00
|
|
|
|
<template #outer>
|
2023-02-26 14:41:18 -06:00
|
|
|
|
<div class="absolute top-8 left-4 z-40">
|
2023-12-03 17:37:01 -06:00
|
|
|
|
<p class="text-white text-2xl truncate">{{ $strings.LabelPlaybackSpeed }}</p>
|
2021-11-02 19:44:42 -05:00
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
2022-06-06 17:19:02 -05:00
|
|
|
|
<div class="w-full h-full overflow-hidden absolute top-0 left-0 flex items-center justify-center">
|
2023-12-10 17:53:27 -06:00
|
|
|
|
<div class="w-full overflow-x-hidden overflow-y-auto bg-primary rounded-lg border border-border" style="max-height: 75%" @click.stop>
|
2021-12-11 13:20:20 -06:00
|
|
|
|
<ul class="w-full" role="listbox" aria-labelledby="listbox-label">
|
2021-09-04 12:31:00 -05:00
|
|
|
|
<template v-for="rate in rates">
|
2023-12-10 17:53:27 -06:00
|
|
|
|
<li :key="rate" class="text-fg select-none relative py-4" :class="rate === selected ? 'bg-bg-hover/50' : ''" role="option" @click="clickedOption(rate)">
|
2021-09-04 12:31:00 -05:00
|
|
|
|
<div class="flex items-center justify-center">
|
2021-11-02 19:44:42 -05:00
|
|
|
|
<span class="font-normal block truncate text-lg">{{ rate }}x</span>
|
2021-09-04 12:31:00 -05:00
|
|
|
|
</div>
|
|
|
|
|
</li>
|
|
|
|
|
</template>
|
|
|
|
|
</ul>
|
2023-12-10 17:53:27 -06:00
|
|
|
|
<div class="flex items-center justify-center py-3 border-t border-fg/10">
|
|
|
|
|
<button :disabled="!canDecrement" @click="decrement" class="icon-num-btn w-8 h-8 text-fg-muted rounded border border-border flex items-center justify-center">
|
2025-03-30 23:26:14 -07:00
|
|
|
|
<span class="material-symbols">remove</span>
|
2021-12-11 13:20:20 -06:00
|
|
|
|
</button>
|
|
|
|
|
<div class="w-24 text-center">
|
|
|
|
|
<p class="text-xl">{{ playbackRate }}<span class="text-lg">⨯</span></p>
|
|
|
|
|
</div>
|
2023-12-10 17:53:27 -06:00
|
|
|
|
<button :disabled="!canIncrement" @click="increment" class="icon-num-btn w-8 h-8 text-fg-muted rounded border border-border flex items-center justify-center">
|
2025-03-30 23:26:14 -07:00
|
|
|
|
<span class="material-symbols">add</span>
|
2021-12-11 13:20:20 -06:00
|
|
|
|
</button>
|
|
|
|
|
</div>
|
2021-09-04 12:31:00 -05:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</modals-modal>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
props: {
|
|
|
|
|
value: Boolean,
|
2021-12-11 13:20:20 -06:00
|
|
|
|
playbackRate: Number
|
2021-09-04 12:31:00 -05:00
|
|
|
|
},
|
|
|
|
|
data() {
|
2021-12-11 13:20:20 -06:00
|
|
|
|
return {
|
|
|
|
|
currentPlaybackRate: 0,
|
|
|
|
|
MIN_SPEED: 0.5,
|
2023-01-16 17:34:42 -06:00
|
|
|
|
MAX_SPEED: 10
|
2021-12-11 13:20:20 -06:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
show(newVal) {
|
|
|
|
|
if (newVal) {
|
|
|
|
|
this.currentPlaybackRate = this.selected
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-09-04 12:31:00 -05:00
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
show: {
|
|
|
|
|
get() {
|
|
|
|
|
return this.value
|
|
|
|
|
},
|
|
|
|
|
set(val) {
|
|
|
|
|
this.$emit('input', val)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
selected: {
|
|
|
|
|
get() {
|
2021-12-11 13:20:20 -06:00
|
|
|
|
return this.playbackRate
|
2021-09-04 12:31:00 -05:00
|
|
|
|
},
|
|
|
|
|
set(val) {
|
2021-12-11 13:20:20 -06:00
|
|
|
|
this.$emit('update:playbackRate', val)
|
2021-09-04 12:31:00 -05:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
rates() {
|
2024-04-19 14:39:00 -05:00
|
|
|
|
return [0.5, 1, 1.2, 1.5, 1.7, 2, 3]
|
2021-12-11 13:20:20 -06:00
|
|
|
|
},
|
|
|
|
|
canIncrement() {
|
|
|
|
|
return this.playbackRate + 0.1 <= this.MAX_SPEED
|
|
|
|
|
},
|
|
|
|
|
canDecrement() {
|
|
|
|
|
return this.playbackRate - 0.1 >= this.MIN_SPEED
|
2021-09-04 12:31:00 -05:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
2021-12-11 13:20:20 -06:00
|
|
|
|
increment() {
|
|
|
|
|
if (this.selected + 0.1 > this.MAX_SPEED) return
|
|
|
|
|
var newPlaybackRate = this.selected + 0.1
|
|
|
|
|
this.selected = Number(newPlaybackRate.toFixed(1))
|
|
|
|
|
},
|
|
|
|
|
decrement() {
|
|
|
|
|
if (this.selected - 0.1 < this.MIN_SPEED) return
|
|
|
|
|
var newPlaybackRate = this.selected - 0.1
|
|
|
|
|
this.selected = Number(newPlaybackRate.toFixed(1))
|
|
|
|
|
},
|
2022-06-06 17:19:02 -05:00
|
|
|
|
modalInput(val) {
|
|
|
|
|
if (!val) {
|
|
|
|
|
if (this.currentPlaybackRate !== this.selected) {
|
|
|
|
|
this.$emit('change', this.selected)
|
|
|
|
|
}
|
2021-09-04 12:31:00 -05:00
|
|
|
|
}
|
2021-12-11 13:20:20 -06:00
|
|
|
|
},
|
|
|
|
|
clickedOption(rate) {
|
|
|
|
|
this.selected = Number(rate)
|
2022-06-06 17:19:02 -05:00
|
|
|
|
this.show = false
|
|
|
|
|
this.$emit('change', Number(rate))
|
2021-09-04 12:31:00 -05:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted() {}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
2021-12-11 13:20:20 -06:00
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
button.icon-num-btn:disabled {
|
|
|
|
|
cursor: not-allowed;
|
|
|
|
|
}
|
|
|
|
|
button.icon-num-btn:disabled::before {
|
|
|
|
|
background-color: rgba(0, 0, 0, 0.2);
|
|
|
|
|
}
|
|
|
|
|
button.icon-num-btn:disabled span {
|
|
|
|
|
color: #777;
|
|
|
|
|
}
|
2025-03-30 23:26:14 -07:00
|
|
|
|
</style>
|