From 97a3a38c0fb07b52e70cba459d1b92273fb57b46 Mon Sep 17 00:00:00 2001 From: mehekj Date: Thu, 11 Nov 2021 16:33:47 -0500 Subject: collapses audio controls when node is resized, preliminary setup for currently playing audio "mini player" --- src/client/views/nodes/AudioBox.scss | 3 +- src/client/views/nodes/AudioBox.tsx | 58 ++++++++++++++++++++++++++---------- 2 files changed, 43 insertions(+), 18 deletions(-) (limited to 'src/client/views/nodes') diff --git a/src/client/views/nodes/AudioBox.scss b/src/client/views/nodes/AudioBox.scss index 681a6b022..76043bfd4 100644 --- a/src/client/views/nodes/AudioBox.scss +++ b/src/client/views/nodes/AudioBox.scss @@ -86,7 +86,7 @@ overflow: hidden; display: flex; flex-direction: column; - align-items: space-between; + align-items: center; background: $dark-gray; width: 100%; height: 100%; @@ -159,7 +159,6 @@ .controls-left { display: flex; flex-direction: row; - width: 100px; } .controls-right { diff --git a/src/client/views/nodes/AudioBox.tsx b/src/client/views/nodes/AudioBox.tsx index dbcd8c8b8..acd025fbd 100644 --- a/src/client/views/nodes/AudioBox.tsx +++ b/src/client/views/nodes/AudioBox.tsx @@ -38,6 +38,8 @@ enum media_state { } @observer export class AudioBox extends ViewBoxAnnotatableComponent(AudioDocument) { + @observable public static CurrentlyPlaying: AudioBox[]; + public static LayoutString(fieldKey: string) { return FieldView.LayoutString(AudioBox, fieldKey); } public static SetScrubTime = action((timeInMillisFrom1970: number) => { AudioBox._scrubTime = 0; @@ -70,6 +72,7 @@ export class AudioBox extends ViewBoxAnnotatableComponent { + // IN PROGRESS: current attempt to make interface for keeping track of audio that is playing + if (!AudioBox.CurrentlyPlaying) { + AudioBox.CurrentlyPlaying = []; + } + if (AudioBox.CurrentlyPlaying.indexOf(this) == -1) { + AudioBox.CurrentlyPlaying.push(this); + } + 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 @@ -166,6 +177,8 @@ export class AudioBox extends ViewBoxAnnotatableComponent { this.Pause(false); if (fullPlay) this.setPlayheadTime(this.timeline!.trimStart); + // removes from currently playing if playback has reached end of range marker + else this.removeCurrentlyPlaying(); }, (end - start) * 1000); } else { @@ -174,6 +187,12 @@ export class AudioBox extends ViewBoxAnnotatableComponent { + AudioBox.CurrentlyPlaying.splice(AudioBox.CurrentlyPlaying.indexOf(this), 1); + } + // update the recording time updateRecordTime = () => { if (this.mediaState === media_state.Recording) { @@ -447,7 +466,11 @@ export class AudioBox extends ViewBoxAnnotatableComponent + return
-
- -
+ {!this.miniPlayer && +
+ +
}
- { e.stopPropagation(); }} onChange={(e: React.ChangeEvent) => { this.setVolume(Number(e.target.value)) }} @@ -476,7 +500,7 @@ export class AudioBox extends ViewBoxAnnotatableComponent
-
+
{this.renderTimeline}
@@ -488,14 +512,16 @@ export class AudioBox extends ViewBoxAnnotatableComponent {this.timeline && formatTime(Math.round(NumCast(this.layoutDoc._currentTimecode) - NumCast(this.timeline.clipStart)))}
-
- - { e.stopPropagation(); }} - onChange={(e: React.ChangeEvent) => { this.zoom(Number(e.target.value)); }} - /> -
+ {!this.miniPlayer && +
+ + { e.stopPropagation(); }} + onChange={(e: React.ChangeEvent) => { this.zoom(Number(e.target.value)); }} + /> +
} +
{this.timeline && formatTime(Math.round(this.timeline.clipDuration))}
-- cgit v1.2.3-70-g09d2