recently played now sets the queue

This commit is contained in:
Violet Caulfield
2024-12-31 07:40:42 -06:00
parent 456596dc40
commit beb891bcdd
2 changed files with 10 additions and 6 deletions

View File

@@ -23,7 +23,7 @@ export default function RecentlyPlayed(): React.JSX.Element {
<View>
<H2>Play it again</H2>
<ScrollView horizontal>
{ recentTracks && recentTracks.map((recentlyPlayedTrack) => {
{ recentTracks && recentTracks.map((recentlyPlayedTrack, index) => {
return (
<Card
caption={recentlyPlayedTrack.Name}
@@ -34,8 +34,8 @@ export default function RecentlyPlayed(): React.JSX.Element {
marginRight={20}
onPress={async () => {
await resetQueue(false);
await addToQueue([mapDtoToTrack(apiClient!, sessionId, recentlyPlayedTrack)])
play();
await addToQueue(recentTracks.map((track) => mapDtoToTrack(apiClient!, sessionId, track)));
play(index);
}}
/>
)

View File

@@ -15,7 +15,7 @@ interface PlayerContext {
showMiniplayer: boolean;
setShowMiniplayer: React.Dispatch<SetStateAction<boolean>>;
queue: JellifyTrack[];
play: () => Promise<void>,
play: (index?: number | undefined) => Promise<void>,
pause: () => Promise<void>,
resetQueue: (hideMiniplayer : boolean | undefined) => Promise<void>;
addToQueue: (tracks: JellifyTrack[]) => Promise<void>;
@@ -37,7 +37,11 @@ const PlayerContextInitializer = () => {
//#region Functions
const play = async () => {
const play = async (index?: number | undefined) => {
if (index)
TrackPlayer.skip(index)
TrackPlayer.play();
const activeTrack = await TrackPlayer.getActiveTrack() as JellifyTrack;
@@ -117,7 +121,7 @@ export const PlayerContext = createContext<PlayerContext>({
showMiniplayer: false,
setShowMiniplayer: () => {},
queue: [],
play: async () => {},
play: async (index?: number | undefined) => {},
pause: async () => {},
resetQueue: async () => {},
addToQueue: async ([]) => {},