aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/AudioBox.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/AudioBox.tsx')
-rw-r--r--src/client/views/nodes/AudioBox.tsx17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/client/views/nodes/AudioBox.tsx b/src/client/views/nodes/AudioBox.tsx
index 6850c2f6c..dbcd8c8b8 100644
--- a/src/client/views/nodes/AudioBox.tsx
+++ b/src/client/views/nodes/AudioBox.tsx
@@ -150,6 +150,7 @@ export class AudioBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProp
// play back the audio from time
@action
playFrom = (seekTimeInSeconds: number, endTime?: number, fullPlay: boolean = false) => {
+ fullPlay = endTime ? fullPlay : true;
clearTimeout(this._play); // abort any previous clip ending
if (Number.isNaN(this._ele?.duration)) { // audio element isn't loaded yet... wait 1/2 second and try again
setTimeout(() => this.playFrom(seekTimeInSeconds, endTime), 500);
@@ -163,12 +164,12 @@ export class AudioBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProp
this.mediaState = media_state.Playing;
this._play = setTimeout(
() => {
- this.Pause();
+ this.Pause(false);
if (fullPlay) this.setPlayheadTime(this.timeline!.trimStart);
},
(end - start) * 1000);
} else {
- this.Pause();
+ this.Pause(false);
}
}
}
@@ -267,7 +268,7 @@ export class AudioBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProp
// pause play back
@action
- Pause = (timeoutClear: boolean = false) => {
+ Pause = (timeoutClear: boolean = true) => {
this._ele?.pause();
this.mediaState = media_state.Paused;
if (timeoutClear) clearTimeout(this._play); // prevents jump back to beginning when manually paused
@@ -298,7 +299,7 @@ export class AudioBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProp
// ref for updating time
setRef = (e: HTMLAudioElement | null) => {
e?.addEventListener("timeupdate", this.timecodeChanged);
- e?.addEventListener("ended", () => this.Pause());
+ e?.addEventListener("ended", () => this.Pause(false));
this._ele = e;
}
@@ -359,13 +360,13 @@ export class AudioBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProp
@undoBatch
finishTrim = () => { // hides trim controls and displays new clip
- this.Pause(true);
+ this.Pause();
this.setPlayheadTime(Math.max(Math.min(this.timeline?.trimEnd || 0, this._ele!.currentTime), this.timeline?.trimStart || 0));
this.timeline?.StopTrimming();
}
startTrim = (scope: TrimScope) => {
- this.Pause(true);
+ this.Pause();
this.timeline?.StartTrimming(scope);
}
@@ -375,7 +376,7 @@ export class AudioBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProp
if (doubleTap) {
this.startTrim(TrimScope.All);
} else if (this.timeline) {
- this.Pause(true);
+ this.Pause();
this.timeline.IsTrimming !== TrimScope.None ? this.finishTrim() : this.startTrim(TrimScope.Clip);
}
}));
@@ -451,7 +452,7 @@ export class AudioBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProp
<div className="controls-left">
<div className="audiobox-button"
title={this.mediaState === media_state.Paused ? "play" : "pause"}
- onPointerDown={this.mediaState === media_state.Paused ? this.Play : (e) => { e.stopPropagation(); this.Pause(true); }}>
+ onPointerDown={this.mediaState === media_state.Paused ? this.Play : (e) => { e.stopPropagation(); this.Pause(); }}>
<FontAwesomeIcon icon={this.mediaState === media_state.Paused ? "play" : "pause"} size={"1x"} />
</div>