mirror of https://github.com/vector-im/riot-web
Merge pull request #6035 from matrix-org/travis/voicemessages/playback-time
Improve progress bar progression for smaller voice messagespull/21833/head
commit
55eddae096
|
@ -57,8 +57,8 @@ export default class PlaybackWaveform extends React.PureComponent<IProps, IState
|
||||||
};
|
};
|
||||||
|
|
||||||
private onTimeUpdate = (time: number[]) => {
|
private onTimeUpdate = (time: number[]) => {
|
||||||
// Track percentages to very coarse precision, otherwise 0.002 ends up highlighting a bar.
|
// Track percentages to a general precision to avoid over-waking the component.
|
||||||
const progress = Number(percentageOf(time[0], 0, time[1]).toFixed(1));
|
const progress = Number(percentageOf(time[0], 0, time[1]).toFixed(3));
|
||||||
this.setState({progress});
|
this.setState({progress});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -138,6 +138,7 @@ export class Playback extends EventEmitter implements IDestroyable {
|
||||||
this.waveformObservable.update(this.resampledWaveform);
|
this.waveformObservable.update(this.resampledWaveform);
|
||||||
|
|
||||||
this.emit(PlaybackState.Stopped); // signal that we're not decoding anymore
|
this.emit(PlaybackState.Stopped); // signal that we're not decoding anymore
|
||||||
|
this.clock.flagLoadTime(); // must happen first because setting the duration fires a clock update
|
||||||
this.clock.durationSeconds = this.audioBuf.duration;
|
this.clock.durationSeconds = this.audioBuf.duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,15 @@ export class PlaybackClock implements IDestroyable {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark the time in the audio context where the clip starts/has been loaded.
|
||||||
|
* This is to ensure the clock isn't skewed into thinking it is ~0.5s into
|
||||||
|
* a clip when the duration is set.
|
||||||
|
*/
|
||||||
|
public flagLoadTime() {
|
||||||
|
this.clipStart = this.context.currentTime;
|
||||||
|
}
|
||||||
|
|
||||||
public flagStart() {
|
public flagStart() {
|
||||||
if (this.stopped) {
|
if (this.stopped) {
|
||||||
this.clipStart = this.context.currentTime;
|
this.clipStart = this.context.currentTime;
|
||||||
|
|
Loading…
Reference in New Issue