You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-08-04 23:02:14 +03:00
Broadcast time left should never be negative (#10070)
This commit is contained in:
@@ -441,7 +441,9 @@ export class VoiceBroadcastPlayback
|
|||||||
}
|
}
|
||||||
|
|
||||||
public get timeLeftSeconds(): number {
|
public get timeLeftSeconds(): number {
|
||||||
return Math.round(this.durationSeconds) - this.timeSeconds;
|
// Sometimes the meta data and the audio files are a little bit out of sync.
|
||||||
|
// Be sure it never returns a negative value.
|
||||||
|
return Math.max(0, Math.round(this.durationSeconds) - this.timeSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async skipTo(timeSeconds: number): Promise<void> {
|
public async skipTo(timeSeconds: number): Promise<void> {
|
||||||
|
@@ -525,6 +525,20 @@ describe("VoiceBroadcastPlayback", () => {
|
|||||||
|
|
||||||
it("should update the time", () => {
|
it("should update the time", () => {
|
||||||
expect(playback.timeSeconds).toBe(11);
|
expect(playback.timeSeconds).toBe(11);
|
||||||
|
expect(playback.timeLeftSeconds).toBe(2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("and the chunk playback progresses across the actual time", () => {
|
||||||
|
// This can be the case if the meta data is out of sync with the actual audio data.
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
chunk1Playback.clockInfo.liveData.update([15]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should update the time", () => {
|
||||||
|
expect(playback.timeSeconds).toBe(15);
|
||||||
|
expect(playback.timeLeftSeconds).toBe(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user