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,
|
Play,
|
||||||
Repeat,
|
Repeat,
|
||||||
Repeat1,
|
Repeat1,
|
||||||
|
RotateCcw,
|
||||||
SkipForward,
|
SkipForward,
|
||||||
Square,
|
Square,
|
||||||
Volume,
|
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 skip = () => run(() => api.skip(), 'Pominięto utwór', 'Błąd pomijania utworu')
|
||||||
|
|
||||||
const stop = () =>
|
const stop = () =>
|
||||||
@@ -248,6 +261,14 @@ async function cycleLoop() {
|
|||||||
>
|
>
|
||||||
<Square />
|
<Square />
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
class="btn-icon btn-secondary"
|
||||||
|
:disabled="!current || duration <= 0 || seekSubmitting"
|
||||||
|
title="Od początku"
|
||||||
|
@click="restartCurrent"
|
||||||
|
>
|
||||||
|
<RotateCcw />
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
class="btn-icon btn-primary"
|
class="btn-icon btn-primary"
|
||||||
:disabled="!current"
|
:disabled="!current"
|
||||||
@@ -299,4 +320,10 @@ async function cycleLoop() {
|
|||||||
background: var(--primary);
|
background: var(--primary);
|
||||||
color: var(--bg-card, var(--bg-dark));
|
color: var(--bg-card, var(--bg-dark));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn-icon:disabled {
|
||||||
|
opacity: 0.35;
|
||||||
|
cursor: not-allowed;
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
Reference in new issue
Block a user