feat: add restart button to player panel to seek to the beginning of the track
This commit is contained in:
1 file changed
+27
@@ -7,6 +7,7 @@ import {
|
||||
Play,
|
||||
Repeat,
|
||||
Repeat1,
|
||||
RotateCcw,
|
||||
SkipForward,
|
||||
Square,
|
||||
Volume,
|
||||
@@ -131,6 +132,18 @@ async function commitSeek() {
|
||||
}
|
||||
}
|
||||
|
||||
async function restartCurrent() {
|
||||
if (!current.value || duration.value <= 0 || seekSubmitting.value) return
|
||||
seekPosition.value = 0
|
||||
seekSubmitting.value = true
|
||||
try {
|
||||
await run(() => api.seek(0), 'Uruchomiono utwór od początku', 'Błąd uruchamiania od początku')
|
||||
} finally {
|
||||
seekSubmitting.value = false
|
||||
seeking.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const skip = () => run(() => api.skip(), 'Pominięto utwór', 'Błąd pomijania utworu')
|
||||
|
||||
const stop = () =>
|
||||
@@ -248,6 +261,14 @@ async function cycleLoop() {
|
||||
>
|
||||
<Square />
|
||||
</button>
|
||||
<button
|
||||
class="btn-icon btn-secondary"
|
||||
:disabled="!current || duration <= 0 || seekSubmitting"
|
||||
title="Od początku"
|
||||
@click="restartCurrent"
|
||||
>
|
||||
<RotateCcw />
|
||||
</button>
|
||||
<button
|
||||
class="btn-icon btn-primary"
|
||||
:disabled="!current"
|
||||
@@ -299,4 +320,10 @@ async function cycleLoop() {
|
||||
background: var(--primary);
|
||||
color: var(--bg-card, var(--bg-dark));
|
||||
}
|
||||
|
||||
.btn-icon:disabled {
|
||||
opacity: 0.35;
|
||||
cursor: not-allowed;
|
||||
transform: none;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user