Add voice broadcast playback seekbar (#9529)

This commit is contained in:
Michael Weimann 2022-11-04 11:50:19 +01:00 committed by GitHub
parent 04bc8fb71c
commit 66d0b318bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 339 additions and 70 deletions

View file

@ -52,6 +52,14 @@ function makePlaybackWaveform(input: number[]): number[] {
return arrayRescale(arraySmoothingResample(noiseWaveform, PLAYBACK_WAVEFORM_SAMPLES), 0, 1);
}
export interface PlaybackInterface {
readonly currentState: PlaybackState;
readonly liveData: SimpleObservable<number[]>;
readonly timeSeconds: number;
readonly durationSeconds: number;
skipTo(timeSeconds: number): Promise<void>;
}
export class Playback extends EventEmitter implements IDestroyable, PlaybackInterface {
/**
* Stable waveform for representing a thumbnail of the media. Values are
@ -110,14 +118,6 @@ export class Playback extends EventEmitter implements IDestroyable, PlaybackInte
return this.clock;
}
public get currentState(): PlaybackState {
return this.state;
}
public get isPlaying(): boolean {
return this.currentState === PlaybackState.Playing;
}
public get liveData(): SimpleObservable<number[]> {
return this.clock.liveData;
}
@ -130,6 +130,14 @@ export class Playback extends EventEmitter implements IDestroyable, PlaybackInte
return this.clock.durationSeconds;
}
public get currentState(): PlaybackState {
return this.state;
}
public get isPlaying(): boolean {
return this.currentState === PlaybackState.Playing;
}
public emit(event: PlaybackState, ...args: any[]): boolean {
this.state = event;
super.emit(event, ...args);