fix: audio queue not moving after 2 changes #182

This commit is contained in:
Prayag Prajapati committed 2024-11-23 23:22:56 +05:30
1 parent dd16f3a204
commit 9be02b6392
5 files changed
+63 -43

No files matched your search

+15 -8
View File
@@ -15,7 +15,7 @@ import type IntroMediaInfo from "../types/introMediaInfo";
import type subtitlePlaybackInfo from "../types/subtitlePlaybackInfo";
import { axiosClient } from "./api";
import { generateAudioStreamUrl, playAudio } from "./audioPlayback";
import useQueue, { setQueue, setTrackIndex } from "./queue";
import useQueue, { setQueue } from "./queue";
type PlaybackStore = {
itemName: string | React.Component | undefined | null;
@@ -135,19 +135,26 @@ export const playItemFromQueue = async (
: index === "previous"
? currentItemIndex - 1
: index;
const prevItem = queueItems[currentItemIndex];
const prevItem = queueItems?.[currentItemIndex];
const prevPlaySessionId = usePlaybackStore.getState().playsessionId;
const prevMediaSourceId = usePlaybackStore.getState().mediaSource.id;
const item = queueItems[requestedItemIndex];
if (item.Type === "Audio") {
const item = queueItems?.[requestedItemIndex];
console.log("requestedItemIndex", queueItems);
if (!item?.Id) {
console.error("No item found in queue");
return;
}
if (item?.Type === "Audio" && userId) {
const playbackUrl = generateAudioStreamUrl(
item.Id,
userId,
api?.deviceInfo.id,
api?.basePath,
api?.accessToken,
api.deviceInfo.id,
api.basePath,
api.accessToken,
);
console.log(item);
// console.log(item);
playAudio(playbackUrl, item, undefined);
setQueue(queueItems, requestedItemIndex);
} else {
+3
View File
@@ -4,6 +4,9 @@ import { createWithEqualityFn } from "zustand/traditional";
interface QueueStore {
tracks: BaseItemDto[] | undefined;
/**
* This index number should be equal to index of the item in tracks array to allow seamless playback of items having broken IndexNumber field.
*/
currentItemIndex: number;
}