diff --git a/components/Home/helpers/recently-played.tsx b/components/Home/helpers/recently-played.tsx index 3506ad32..361f7b6c 100644 --- a/components/Home/helpers/recently-played.tsx +++ b/components/Home/helpers/recently-played.tsx @@ -23,7 +23,7 @@ export default function RecentlyPlayed(): React.JSX.Element {

Play it again

- { recentTracks && recentTracks.map((recentlyPlayedTrack) => { + { recentTracks && recentTracks.map((recentlyPlayedTrack, index) => { return ( { await resetQueue(false); - await addToQueue([mapDtoToTrack(apiClient!, sessionId, recentlyPlayedTrack)]) - play(); + await addToQueue(recentTracks.map((track) => mapDtoToTrack(apiClient!, sessionId, track))); + play(index); }} /> ) diff --git a/player/provider.tsx b/player/provider.tsx index 06e09fb1..b98b3ead 100644 --- a/player/provider.tsx +++ b/player/provider.tsx @@ -15,7 +15,7 @@ interface PlayerContext { showMiniplayer: boolean; setShowMiniplayer: React.Dispatch>; queue: JellifyTrack[]; - play: () => Promise, + play: (index?: number | undefined) => Promise, pause: () => Promise, resetQueue: (hideMiniplayer : boolean | undefined) => Promise; addToQueue: (tracks: JellifyTrack[]) => Promise; @@ -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({ showMiniplayer: false, setShowMiniplayer: () => {}, queue: [], - play: async () => {}, + play: async (index?: number | undefined) => {}, pause: async () => {}, resetQueue: async () => {}, addToQueue: async ([]) => {},