Be smart with readonly
This commit is contained in:
parent
79aa205a95
commit
e045aa940e
2 changed files with 7 additions and 10 deletions
|
@ -95,7 +95,7 @@ export default class VoiceRecordComposerTile extends React.PureComponent<IProps,
|
||||||
duration: Math.round(this.state.recorder.durationSeconds * 1000),
|
duration: Math.round(this.state.recorder.durationSeconds * 1000),
|
||||||
|
|
||||||
// https://github.com/matrix-org/matrix-doc/pull/3246
|
// https://github.com/matrix-org/matrix-doc/pull/3246
|
||||||
waveform: this.state.recorder.getPlayback().waveformThumbnail.map(v => Math.round(v * 1024)),
|
waveform: this.state.recorder.getPlayback().thumbnailWaveform.map(v => Math.round(v * 1024)),
|
||||||
},
|
},
|
||||||
"org.matrix.msc3245.voice": {}, // No content, this is a rendering hint
|
"org.matrix.msc3245.voice": {}, // No content, this is a rendering hint
|
||||||
});
|
});
|
||||||
|
|
|
@ -52,12 +52,17 @@ function makePlaybackWaveform(input: number[]): number[] {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Playback extends EventEmitter implements IDestroyable {
|
export class Playback extends EventEmitter implements IDestroyable {
|
||||||
|
/**
|
||||||
|
* Stable waveform for representing a thumbnail of the media. Values are
|
||||||
|
* guaranteed to be between zero and one, inclusive.
|
||||||
|
*/
|
||||||
|
public readonly thumbnailWaveform: number[];
|
||||||
|
|
||||||
private readonly context: AudioContext;
|
private readonly context: AudioContext;
|
||||||
private source: AudioBufferSourceNode;
|
private source: AudioBufferSourceNode;
|
||||||
private state = PlaybackState.Decoding;
|
private state = PlaybackState.Decoding;
|
||||||
private audioBuf: AudioBuffer;
|
private audioBuf: AudioBuffer;
|
||||||
private resampledWaveform: number[];
|
private resampledWaveform: number[];
|
||||||
private thumbnailWaveform: number[];
|
|
||||||
private waveformObservable = new SimpleObservable<number[]>();
|
private waveformObservable = new SimpleObservable<number[]>();
|
||||||
private readonly clock: PlaybackClock;
|
private readonly clock: PlaybackClock;
|
||||||
private readonly fileSize: number;
|
private readonly fileSize: number;
|
||||||
|
@ -95,14 +100,6 @@ export class Playback extends EventEmitter implements IDestroyable {
|
||||||
return this.resampledWaveform;
|
return this.resampledWaveform;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Stable waveform for representing a thumbnail of the media. Values are
|
|
||||||
* guaranteed to be between zero and one, inclusive.
|
|
||||||
*/
|
|
||||||
public get waveformThumbnail(): number[] {
|
|
||||||
return this.thumbnailWaveform;
|
|
||||||
}
|
|
||||||
|
|
||||||
public get waveformData(): SimpleObservable<number[]> {
|
public get waveformData(): SimpleObservable<number[]> {
|
||||||
return this.waveformObservable;
|
return this.waveformObservable;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue