fixing some bugs making it more feasible

This commit is contained in:
talksik
2022-02-20 17:06:29 -08:00
parent 06b5e556ee
commit 1c1c3e59b8
2 changed files with 20 additions and 7 deletions
+17 -7
View File
@@ -50,24 +50,23 @@ export default function AudioHandler() {
const relevantContacts = useRecoilValue(allRelevantContactsAtom);
const onEndedPlaying = (e) => {
console.log('done playing')
toast.dismiss()
// remove from queue and the queue manager will handle the rest
setAudioQueue((prevQueue) => {
const newQueue: AudioClip[] = [...prevQueue];
newQueue.shift();
return newQueue;
});
console.log('done playing')
toast.dismiss()
}
// main effect to play with js
useEffect(() => {
if (playerSrc) {
// play current audio clip
const audio = new Audio(playerSrc);
audio.onended = onEndedPlaying;
audio.play();
// const audio = new Audio(playerSrc);
// audio.onended = onEndedPlaying;
// audio.play();
// have toast showing who is speaking
// find who is speaking if we can
@@ -308,6 +307,17 @@ export default function AudioHandler() {
return (
<>
{playerSrc && (
<AudioPlayer
autoPlay
src={playerSrc}
onPlay={(e) => console.log("onPlay")}
showSkipControls={true}
onEnded={onEndedPlaying}
className="w-screen flex flex-row fixed bottom-0 invisible"
/>
)}
<GlobalHotKeys keyMap={keyMap} handlers={handlers} allowChanges={true} />
</>
);
@@ -3,6 +3,7 @@ import { useRouter } from "next/router";
import { GlobalHotKeys, KeyMap, configure } from "react-hotkeys";
import { selectedConvoAtom, audioQueueAtom } from "../../recoil/main";
import { useSetRecoilState } from "recoil";
import toast from 'react-hot-toast'
export default function KeyboardShortcutHandler() {
const router = useRouter();
@@ -20,6 +21,8 @@ export default function KeyboardShortcutHandler() {
setSelectedPriorityConvo(null);
setAudioQueue([]);
toast.dismiss()
};
const keyMap: KeyMap = {