audio back and forth
This commit is contained in:
parent
a9c1f21fe3
commit
bdd82be393
@ -76,16 +76,20 @@ function controlPlayback(speed) {
|
||||
audioReverse.pause();
|
||||
|
||||
// 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
|
||||
if (speed > 0) {
|
||||
audioForward.playbackRate = normalizedSpeed;
|
||||
audioForward.currentTime = Math.min(audioForward.currentTime, audioForward.duration);
|
||||
audioForward.playbackRate = normalizedSpeed; // Redémarrer la lecture si elle est arrivée à la fin
|
||||
if (audioForward.currentTime >= audioForward.duration) {
|
||||
audioForward.currentTime = 0;
|
||||
}
|
||||
audioForward.play();
|
||||
} else {
|
||||
audioReverse.playbackRate = normalizedSpeed;
|
||||
audioReverse.currentTime = Math.min(audioReverse.currentTime, audioReverse.duration);
|
||||
if (audioReverse.currentTime >= audioReverse.duration) {
|
||||
audioReverse.currentTime = 0;
|
||||
}
|
||||
audioReverse.play();
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user