audio back and forth
This commit is contained in:
parent
a9c1f21fe3
commit
bdd82be393
@ -76,16 +76,20 @@ function controlPlayback(speed) {
|
|||||||
audioReverse.pause();
|
audioReverse.pause();
|
||||||
|
|
||||||
// Calcule la vitesse normalisée (sensibilité appliquée)
|
// Calcule la vitesse normalisée (sensibilité appliquée)
|
||||||
let normalizedSpeed = Math.min(MAX_SPEED, Math.abs(speed) * SENSITIVITY);
|
let normalizedSpeed = Math.min(MAX_SPEED, Math.max(0.5, Math.abs(speed) * SENSITIVITY));
|
||||||
|
|
||||||
// On lit dans le bon sens
|
// On lit dans le bon sens
|
||||||
if (speed > 0) {
|
if (speed > 0) {
|
||||||
audioForward.playbackRate = normalizedSpeed;
|
audioForward.playbackRate = normalizedSpeed; // Redémarrer la lecture si elle est arrivée à la fin
|
||||||
audioForward.currentTime = Math.min(audioForward.currentTime, audioForward.duration);
|
if (audioForward.currentTime >= audioForward.duration) {
|
||||||
|
audioForward.currentTime = 0;
|
||||||
|
}
|
||||||
audioForward.play();
|
audioForward.play();
|
||||||
} else {
|
} else {
|
||||||
audioReverse.playbackRate = normalizedSpeed;
|
audioReverse.playbackRate = normalizedSpeed;
|
||||||
audioReverse.currentTime = Math.min(audioReverse.currentTime, audioReverse.duration);
|
if (audioReverse.currentTime >= audioReverse.duration) {
|
||||||
|
audioReverse.currentTime = 0;
|
||||||
|
}
|
||||||
audioReverse.play();
|
audioReverse.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user