Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #6728 from matrix-org/travis/voice-messages/interr…
Browse files Browse the repository at this point in the history
…upt-text

Stop automatic playback of voice messages if a non-voice message is encountered
  • Loading branch information
turt2live committed Sep 3, 2021
2 parents 60e2d61 + b2cb944 commit 9dee3eb
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/audio/PlaybackQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { arrayFastClone } from "../utils/arrays";
import { PlaybackManager } from "./PlaybackManager";
import { isVoiceMessage } from "../utils/EventUtils";
import RoomViewStore from "../stores/RoomViewStore";
import { EventType } from "matrix-js-sdk/src/@types/event";

/**
* Audio playback queue management for a given room. This keeps track of where the user
Expand Down Expand Up @@ -137,13 +138,17 @@ export class PlaybackQueue {
}
if (!scanForVoiceMessage) continue;

// Dev note: This is where we'd break to cause text/non-voice messages to
// interrupt automatic playback.
if (!isVoiceMessage(event)) {
const evType = event.getType();
if (evType !== EventType.RoomMessage && evType !== EventType.Sticker) {
continue; // Event can be skipped for automatic playback consideration
}
break; // Stop automatic playback: next useful event is not a voice message
}

const isRightType = isVoiceMessage(event);
const havePlayback = this.playbacks.has(event.getId());
const isRecentlyCompleted = this.recentFullPlays.has(event.getId());
if (isRightType && havePlayback && !isRecentlyCompleted) {
if (havePlayback && !isRecentlyCompleted) {
nextEv = event;
break;
}
Expand Down

0 comments on commit 9dee3eb

Please sign in to comment.