@@ -22,7 +22,7 @@ import { ItemPressable } from "@/src/components/ui/pressable/ItemPressable"
2222import { PlayerAction } from "@/src/components/ui/video/PlayerAction"
2323import { useNavigation } from "@/src/lib/navigation/hooks"
2424import { isIOS } from "@/src/lib/platform"
25- import { player , usePlayButtonState } from "@/src/lib/player"
25+ import { player , useAudioPlayState } from "@/src/lib/player"
2626import { toast } from "@/src/lib/toast"
2727import { EntryDetailScreen } from "@/src/screens/(stack)/entries/[entryId]/EntryDetailScreen"
2828
@@ -181,9 +181,7 @@ const ThumbnailImage = ({ entryId }: { entryId: string }) => {
181181 const blurhash = mediaModel ?. blurhash
182182
183183 const audio = entry ?. attachments ?. find ( ( attachment ) => attachment . mime_type ?. startsWith ( "audio/" ) )
184- const audioState = usePlayButtonState ( audio ?. url )
185- const isPlaying = audioState === "pause"
186- const isLoading = audioState === "loading"
184+ const audioState = useAudioPlayState ( audio ?. url )
187185
188186 const video = mediaModel ?. type === "video" ? mediaModel : null
189187 const videoViewRef = useRef < null | VideoView > ( null )
@@ -205,7 +203,7 @@ const ThumbnailImage = ({ entryId }: { entryId: string }) => {
205203 return
206204 }
207205 if ( ! audio ) return
208- if ( isLoading || isPlaying ) {
206+ if ( audioState !== "paused" ) {
209207 player . pause ( )
210208 return
211209 }
@@ -220,7 +218,7 @@ const ThumbnailImage = ({ entryId }: { entryId: string }) => {
220218 console . error ( "Error playing audio:" , error )
221219 toast . error ( "Failed to play audio" )
222220 }
223- } , [ audio , entry ?. title , feed ?. title , image , isLoading , isPlaying , video , videoPlayer ] )
221+ } , [ audio , audioState , entry ?. title , feed ?. title , image , video , videoPlayer ] )
224222
225223 const [ imageError , setImageError ] = useState ( audio && ! image )
226224 const handleImageError = useCallback ( ( ) => {
@@ -272,12 +270,7 @@ const ThumbnailImage = ({ entryId }: { entryId: string }) => {
272270 { /* Show feed icon if no image but audio is present */ }
273271 { imageError && < FeedIcon feed = { feed } size = { 96 } /> }
274272
275- { ( video || audio ) && (
276- < PlayerAction
277- state = { isPlaying ? "pause" : isLoading ? "loading" : "play" }
278- onPress = { handlePressPlay }
279- />
280- ) }
273+ { ( video || audio ) && < PlayerAction mediaState = { audioState } onPress = { handlePressPlay } /> }
281274 </ View >
282275 )
283276}
0 commit comments