whole queue working with the timeline
This commit is contained in:
@@ -43,8 +43,6 @@ export default function AudioHandler() {
|
|||||||
const [audioQueue, setAudioQueue] = useRecoilState(audioQueueAtom);
|
const [audioQueue, setAudioQueue] = useRecoilState(audioQueueAtom);
|
||||||
|
|
||||||
function onEndedPlaying(e) {
|
function onEndedPlaying(e) {
|
||||||
toast.success("finished playing");
|
|
||||||
|
|
||||||
// remove from queue and the queue manager will handle the rest
|
// remove from queue and the queue manager will handle the rest
|
||||||
setAudioQueue((prevQueue) => {
|
setAudioQueue((prevQueue) => {
|
||||||
const newQueue: AudioClip[] = [...prevQueue];
|
const newQueue: AudioClip[] = [...prevQueue];
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ export default function TimelineAudioClip(props: {
|
|||||||
index: number;
|
index: number;
|
||||||
audioClip: AudioClip;
|
audioClip: AudioClip;
|
||||||
convoId: string;
|
convoId: string;
|
||||||
|
audioClipsToPlay: AudioClip[];
|
||||||
}) {
|
}) {
|
||||||
const relContactsMap = useRecoilValue(allRelevantContactsAtom);
|
const relContactsMap = useRecoilValue(allRelevantContactsAtom);
|
||||||
const userConvosMap = useRecoilValue(allUsersConversationsAtom);
|
const userConvosMap = useRecoilValue(allUsersConversationsAtom);
|
||||||
@@ -39,8 +40,9 @@ export default function TimelineAudioClip(props: {
|
|||||||
// audio.onloadedmetadata = loadedMetadata;
|
// audio.onloadedmetadata = loadedMetadata;
|
||||||
|
|
||||||
const playAudioClip = () => {
|
const playAudioClip = () => {
|
||||||
|
// current audioclip included in the array of audioclipstoplay
|
||||||
setAudioQueue((prevQueue) => {
|
setAudioQueue((prevQueue) => {
|
||||||
return [...prevQueue, props.audioClip];
|
return [...prevQueue, ...props.audioClipsToPlay];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -277,12 +277,14 @@ export default function ViewConvo(props: { conversationId: string }) {
|
|||||||
{/* have one row, but just translate it along y downward to put it in it's own place */}
|
{/* have one row, but just translate it along y downward to put it in it's own place */}
|
||||||
<span className="flex flex-row flex-nowrap pb-[10rem] py-[5rem] overflow-auto min-h-max">
|
<span className="flex flex-row flex-nowrap pb-[10rem] py-[5rem] overflow-auto min-h-max">
|
||||||
{audioClips.reverse().map((audClip, index) => {
|
{audioClips.reverse().map((audClip, index) => {
|
||||||
|
const restAudioClips = audioClips.slice(index);
|
||||||
return (
|
return (
|
||||||
<TimelineAudioClip
|
<TimelineAudioClip
|
||||||
key={audClip.id}
|
key={audClip.id}
|
||||||
index={index}
|
index={index}
|
||||||
audioClip={audClip}
|
audioClip={audClip}
|
||||||
convoId={props.conversationId}
|
convoId={props.conversationId}
|
||||||
|
audioClipsToPlay={restAudioClips}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
Reference in New Issue
Block a user