diff --git a/app/components/ListItem.tsx b/app/components/ListItem.tsx
index c95d4d2..d4c4be1 100644
--- a/app/components/ListItem.tsx
+++ b/app/components/ListItem.tsx
@@ -2,7 +2,6 @@ import { useStarred } from '@app/hooks/music'
import { AlbumListItem, Artist, ListableItem, Song } from '@app/models/music'
import { selectMusic } from '@app/state/music'
import { useStore } from '@app/state/store'
-import { selectTrackPlayer } from '@app/state/trackplayer'
import colors from '@app/styles/colors'
import font from '@app/styles/font'
import { useNavigation } from '@react-navigation/native'
@@ -17,16 +16,23 @@ import PressableOpacity from './PressableOpacity'
import Star from './Star'
const TitleTextSong = React.memo<{
- id: string
+ isPlaying?: () => boolean
title?: string
-}>(({ id, title }) => {
- const currentTrack = useStore(selectTrackPlayer.currentTrack)
- const playing = currentTrack?.id === id
+}>(({ isPlaying, title }) => {
+ const playing = () => isPlaying && isPlaying()
return (
- {playing ? : <>>}
- {title}
+
+ {playing() ? (
+
+
+
+ ) : (
+ <>>
+ )}
+ {title}
+
)
})
@@ -43,12 +49,13 @@ const TitleText = React.memo<{
const ListItem: React.FC<{
item: ListableItem
+ isPlaying?: () => boolean
onPress?: () => void
showArt?: boolean
showStar?: boolean
listStyle?: 'big' | 'small'
subtitle?: string
-}> = ({ item, onPress, showArt, showStar, subtitle, listStyle }) => {
+}> = ({ item, isPlaying, onPress, showArt, showStar, subtitle, listStyle }) => {
const navigation = useNavigation()
const starred = useStarred(item.id, item.itemType)
@@ -145,7 +152,7 @@ const ListItem: React.FC<{
)}
{item.itemType === 'song' ? (
-
+
) : (
)}
@@ -211,8 +218,8 @@ const styles = StyleSheet.create({
color: colors.text.primary,
},
playingIcon: {
- marginRight: 5,
- marginLeft: 1,
+ paddingRight: 4,
+ paddingBottom: 1,
},
downloadedIcon: {
marginRight: 2,
diff --git a/app/hooks/trackplayer.ts b/app/hooks/trackplayer.ts
index 63a3ce0..8341f37 100644
--- a/app/hooks/trackplayer.ts
+++ b/app/hooks/trackplayer.ts
@@ -243,6 +243,18 @@ export const useSetQueue = () => {
})
}
+export const useIsPlaying = () => {
+ const queueContextId = useStore(selectTrackPlayer.queueContextId)
+ const currentTrackIdx = useStore(selectTrackPlayer.currentTrackIdx)
+
+ return (contextId: string | undefined, track: number) => {
+ if (contextId === undefined) {
+ return track === currentTrackIdx
+ }
+ return contextId === queueContextId && track === currentTrackIdx
+ }
+}
+
function mapSongToTrack(song: Song, coverArtUri: (coverArt?: string) => string | undefined): TrackExt {
return {
id: song.id,
diff --git a/app/screens/ArtistView.tsx b/app/screens/ArtistView.tsx
index d337b1f..64f4d73 100644
--- a/app/screens/ArtistView.tsx
+++ b/app/screens/ArtistView.tsx
@@ -5,7 +5,7 @@ import GradientScrollView from '@app/components/GradientScrollView'
import Header from '@app/components/Header'
import ListItem from '@app/components/ListItem'
import { useArtistInfo } from '@app/hooks/music'
-import { useSetQueue } from '@app/hooks/trackplayer'
+import { useIsPlaying, useSetQueue } from '@app/hooks/trackplayer'
import { Album, Song } from '@app/models/music'
import colors from '@app/styles/colors'
import font from '@app/styles/font'
@@ -45,6 +45,7 @@ const TopSongs = React.memo<{
artistId: string
}>(({ songs, name, artistId }) => {
const setQueue = useSetQueue()
+ const isPlaying = useIsPlaying()
return (
<>
@@ -53,6 +54,7 @@ const TopSongs = React.memo<{
isPlaying(artistId, i)}
showArt={true}
subtitle={s.album}
onPress={() => setQueue(songs, name, 'artist', artistId, i)}
diff --git a/app/screens/NowPlayingQueue.tsx b/app/screens/NowPlayingQueue.tsx
index d89e01e..9a858ba 100644
--- a/app/screens/NowPlayingQueue.tsx
+++ b/app/screens/NowPlayingQueue.tsx
@@ -1,7 +1,7 @@
import GradientScrollView from '@app/components/GradientScrollView'
import ListItem from '@app/components/ListItem'
import NowPlayingBar from '@app/components/NowPlayingBar'
-import { mapTrackExtToSong, useSkipTo } from '@app/hooks/trackplayer'
+import { mapTrackExtToSong, useIsPlaying, useSkipTo } from '@app/hooks/trackplayer'
import { useStore } from '@app/state/store'
import { selectTrackPlayer } from '@app/state/trackplayer'
import React from 'react'
@@ -10,6 +10,7 @@ import { StyleSheet, View } from 'react-native'
const NowPlayingQueue = React.memo<{}>(() => {
const queue = useStore(selectTrackPlayer.queue)
const skipTo = useSkipTo()
+ const isPlaying = useIsPlaying()
return (
@@ -19,6 +20,7 @@ const NowPlayingQueue = React.memo<{}>(() => {
isPlaying(undefined, i)}
onPress={() => skipTo(i)}
showArt={true}
subtitle={`${song.artist} • ${song.album}`}
diff --git a/app/screens/Search.tsx b/app/screens/Search.tsx
index 74b58bc..b1541ba 100644
--- a/app/screens/Search.tsx
+++ b/app/screens/Search.tsx
@@ -3,7 +3,7 @@ import Header from '@app/components/Header'
import ListItem from '@app/components/ListItem'
import NothingHere from '@app/components/NothingHere'
import { useActiveListRefresh2 } from '@app/hooks/server'
-import { useSetQueue } from '@app/hooks/trackplayer'
+import { useIsPlaying, useSetQueue } from '@app/hooks/trackplayer'
import { ListableItem, SearchResults, Song } from '@app/models/music'
import { selectMusic } from '@app/state/music'
import { useStore } from '@app/state/store'
@@ -15,10 +15,12 @@ import { ActivityIndicator, StatusBar, StyleSheet, TextInput, View } from 'react
const SongItem = React.memo<{ item: Song }>(({ item }) => {
const setQueue = useSetQueue()
+ const isPlaying = useIsPlaying()
return (
isPlaying(item.id, 0)}
showArt={true}
showStar={false}
onPress={() => setQueue([item], item.title, 'song', item.id, 0)}
diff --git a/app/screens/SongListView.tsx b/app/screens/SongListView.tsx
index a86ceef..89fa4a3 100644
--- a/app/screens/SongListView.tsx
+++ b/app/screens/SongListView.tsx
@@ -5,7 +5,7 @@ import ListItem from '@app/components/ListItem'
import ListPlayerControls from '@app/components/ListPlayerControls'
import NothingHere from '@app/components/NothingHere'
import { useAlbumWithSongs, useCoverArtUri, usePlaylistWithSongs } from '@app/hooks/music'
-import { useSetQueue } from '@app/hooks/trackplayer'
+import { useIsPlaying, useSetQueue } from '@app/hooks/trackplayer'
import { AlbumWithSongs, PlaylistWithSongs, Song } from '@app/models/music'
import colors from '@app/styles/colors'
import font from '@app/styles/font'
@@ -28,6 +28,7 @@ const Songs = React.memo<{
itemId: string
}>(({ songs, name, type, itemId }) => {
const setQueue = useSetQueue()
+ const isPlaying = useIsPlaying()
const _songs = [...songs]
let typeName = ''
@@ -56,6 +57,7 @@ const Songs = React.memo<{
isPlaying(itemId, i)}
subtitle={s.artist}
onPress={() => setQueue(songs, name, type, itemId, i)}
showArt={type === 'playlist'}