From 0e702bb8526392da5daa9f63e12010a86d2aff3d Mon Sep 17 00:00:00 2001 From: Rem Helper Date: Mon, 6 Jul 2026 01:24:19 +0000 Subject: [PATCH] Hide player bar when queue is empty - Stop showing the mini player when there is no queued track - Reset playback state to 0 and paused at end of queue - Keep the current song in queue history when skipping the last track --- apps/mobile/app/(app)/(tabs)/_layout.tsx | 11 ++++++++--- apps/mobile/contexts/playback.tsx | 13 +++++++++++++ apps/web/components/playback-provider.tsx | 13 +++++++++++++ packages/convex/convex/playback.ts | 7 +++---- 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/apps/mobile/app/(app)/(tabs)/_layout.tsx b/apps/mobile/app/(app)/(tabs)/_layout.tsx index 075ee6e..6620e89 100644 --- a/apps/mobile/app/(app)/(tabs)/_layout.tsx +++ b/apps/mobile/app/(app)/(tabs)/_layout.tsx @@ -4,6 +4,7 @@ import { DynamicColorIOS, Platform, useColorScheme } from "react-native" import { useMemo } from "react" import { TabBottomAccessory } from "@/components/mini-player" +import { usePlayback } from "@/contexts/playback" import { appleMusic, colors } from "@/lib/theme" function useRouterTheme() { @@ -75,6 +76,8 @@ function useNativeTabColors() { export default function TabsLayout() { const routerTheme = useRouterTheme() const tabColors = useNativeTabColors() + const { currentSong, queueSongIds } = usePlayback() + const showBottomAccessory = Boolean(currentSong && queueSongIds.length > 0) return ( @@ -90,9 +93,11 @@ export default function TabsLayout() { tintColor={appleMusic.pink} minimizeBehavior="onScrollDown" > - - - + {showBottomAccessory ? ( + + + + ) : null} diff --git a/apps/mobile/contexts/playback.tsx b/apps/mobile/contexts/playback.tsx index df05584..d50356b 100644 --- a/apps/mobile/contexts/playback.tsx +++ b/apps/mobile/contexts/playback.tsx @@ -236,7 +236,15 @@ export function PlaybackProvider({ children }: { children: ReactNode }) { autoPlayNextRef.current = true isPlayingRef.current = true setIsPlayingState(true) + return } + + autoPlayNextRef.current = false + isPlayingRef.current = false + void playerRef.current?.seekTo(0) + currentTimeRef.current = 0 + setCurrentTime(0) + setIsPlayingState(false) }) .catch(() => { autoPlayNextRef.current = false @@ -655,7 +663,12 @@ export function PlaybackProvider({ children }: { children: ReactNode }) { await skipToQueueIndexMutation({ index }) }, skipNext: async () => { + const isFinishingQueue = repeatEnabled === "none" && queueLength <= 1 await skipNextMutation() + if (isFinishingQueue) { + await seekTo(0) + setIsPlaying(false) + } }, skipPrevious: async () => { if (currentTime > PREVIOUS_TRACK_RESTART_THRESHOLD_SECONDS) { diff --git a/apps/web/components/playback-provider.tsx b/apps/web/components/playback-provider.tsx index 4f7b9b5..370c2c1 100644 --- a/apps/web/components/playback-provider.tsx +++ b/apps/web/components/playback-provider.tsx @@ -790,7 +790,14 @@ export function PlaybackProvider({ children }: { children: ReactNode }) { autoPlayNextRef.current = true isPlayingRef.current = true setIsPlaying(true) + return } + + autoPlayNextRef.current = false + isPlayingRef.current = false + audio.currentTime = 0 + setCurrentTime(0) + setIsPlaying(false) }) .catch(() => { autoPlayNextRef.current = false @@ -1066,7 +1073,13 @@ export function PlaybackProvider({ children }: { children: ReactNode }) { await skipToQueueIndexMutation({ index }) }, skipNext: async () => { + const isFinishingQueue = + repeatEnabled === "none" && queueSongIds.length <= 1 await skipNextMutation() + if (isFinishingQueue) { + seekTo(0) + setIsPlaying(false) + } }, skipPrevious: async () => { if (currentTime > PREVIOUS_TRACK_RESTART_THRESHOLD_SECONDS) { diff --git a/packages/convex/convex/playback.ts b/packages/convex/convex/playback.ts index 955a483..b67cb08 100644 --- a/packages/convex/convex/playback.ts +++ b/packages/convex/convex/playback.ts @@ -511,17 +511,16 @@ export const skipNext = mutation({ return } - const history = appendToQueueHistory(user.queueHistory ?? [], current) - if (rest.length === 0) { await ctx.db.patch(userId, { - songQueue: [], - queueHistory: history, + songQueue: [current], currentSongProgress: 0, }) return } + const history = appendToQueueHistory(user.queueHistory ?? [], current) + await ctx.db.patch(userId, { songQueue: rest, queueHistory: history,