nice improvements to the audio queue

This commit is contained in:
Arjun Patel
2022-01-22 00:53:23 -08:00
parent 892d3f7dd4
commit a1ef8f7883
3 changed files with 11 additions and 4 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ export default function AnnouncementCard(props: IAnnouncementCardProps) {
const [loading, setLoading] = useState<boolean>(false);
function playAnnouncement() {
handleAddAudioToQueue([props.announcement.audioDataUrl]);
handleAddAudioToQueue([props.announcement.audioDataUrl], true);
}
async function resolveAnnouncement() {
+1 -1
View File
@@ -38,7 +38,7 @@ export default function PowerPlayer(props: {
// // loop through start to end and add to queue
// var convoChunk: string[] = []
handleAddAudioToQueue([url]);
handleAddAudioToQueue([url], true);
}
function handleClose(e) {
+9 -2
View File
@@ -548,8 +548,15 @@ export default function KeyboardContextProvider({ children }) {
const [playerSrc, setPlayerSrc] = useState<string>(null);
function handleAddAudioToQueue(urls: string[]) {
setAudioQueue((prevQueue) => [...prevQueue, ...urls]);
function handleAddAudioToQueue(
urls: string[],
clearEverythingElse: boolean = false
) {
if (clearEverythingElse) {
setAudioQueue(urls);
} else {
setAudioQueue((prevQueue) => [...prevQueue, ...urls]);
}
}
function startAnnouncement() {