aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormehekj <mehek.jethani@gmail.com>2021-11-09 16:04:24 -0500
committermehekj <mehek.jethani@gmail.com>2021-11-09 16:04:24 -0500
commitdee64c39f722dfa9502bd5b590aa4349e053784e (patch)
tree795aebc61d87dabbbb63a46e6c0195a4b43950b5
parentffbd40b2a8ebdd49b4bc08b8edaf8aee699d12d3 (diff)
fixed clearTimeout defaults and label marker playback
-rw-r--r--src/client/views/collections/CollectionStackedTimeline.tsx10
-rw-r--r--src/client/views/nodes/AudioBox.tsx17
2 files changed, 14 insertions, 13 deletions
diff --git a/src/client/views/collections/CollectionStackedTimeline.tsx b/src/client/views/collections/CollectionStackedTimeline.tsx
index 5352b5220..8c98afdb3 100644
--- a/src/client/views/collections/CollectionStackedTimeline.tsx
+++ b/src/client/views/collections/CollectionStackedTimeline.tsx
@@ -52,7 +52,7 @@ type PanZoomDocument = makeInterface<[]>;
const PanZoomDocument = makeInterface();
export type CollectionStackedTimelineProps = {
Play: () => void;
- Pause: (timeoutClear: boolean) => void;
+ Pause: () => void;
playLink: (linkDoc: Doc) => void;
playFrom: (seekTimeInSeconds: number, endTime?: number) => void;
playing: () => boolean;
@@ -227,7 +227,7 @@ export class CollectionStackedTimeline extends CollectionSubView<
const shiftKey = e.shiftKey;
if (rect && this.props.isContentActive()) {
const wasPlaying = this.props.playing();
- if (wasPlaying) this.props.Pause(true);
+ if (wasPlaying) this.props.Pause();
var wasSelecting = this._markerEnd !== undefined;
setupMoveUpEvents(
this,
@@ -429,7 +429,7 @@ export class CollectionStackedTimeline extends CollectionSubView<
const seekTimeInSeconds = this.anchorStart(anchorDoc) - 0.25;
const endTime = this.anchorEnd(anchorDoc);
if (this.layoutDoc.autoPlayAnchors) {
- if (this.props.playing()) this.props.Pause(true);
+ if (this.props.playing()) this.props.Pause();
else {
this.props.playFrom(seekTimeInSeconds, endTime);
this.scrollToTime(seekTimeInSeconds);
@@ -440,7 +440,7 @@ export class CollectionStackedTimeline extends CollectionSubView<
endTime > NumCast(this.layoutDoc._currentTimecode)
) {
if (!this.layoutDoc.autoPlayAnchors && this.props.playing()) {
- this.props.Pause(true);
+ this.props.Pause();
} else {
this.props.Play();
}
@@ -463,7 +463,7 @@ export class CollectionStackedTimeline extends CollectionSubView<
seekTimeInSeconds < NumCast(this.layoutDoc._currentTimecode) + 1e-4 &&
endTime > NumCast(this.layoutDoc._currentTimecode) - 1e-4
) {
- if (this.props.playing()) this.props.Pause(true);
+ if (this.props.playing()) this.props.Pause();
else if (this.layoutDoc.autoPlayAnchors) this.props.Play();
else if (!this.layoutDoc.autoPlayAnchors) {
const rect = this._timeline?.getBoundingClientRect();
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>