Skip to content

Commit f1674e2

Browse files
cursor[bot]cursoragentraymondjacobson
authored
Fix mobile lock-screen artwork mirror fallback (#13917)
Update mobile audio lock-screen metadata to resolve artwork URLs with mirror fallback and preferred size selection, and export the shared resolveImageUrl utility from common utils. <div><a href="https://cursor.com/agents/bc-2343093a-5a18-4b34-a1bc-cc511a3e3ec4"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/automations/c63aa103-66df-4558-b31d-675358e5c6a1"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/view-automation-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/view-automation-light.png"><img alt="View Automation" width="141" height="28" src="https://cursor.com/assets/images/view-automation-dark.png"></picture></a>&nbsp;</div> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Ray Jacobson <raymondjacobson@users.noreply.github.com>
1 parent f1c16db commit f1674e2

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

packages/common/src/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export * from './sagaHelpers'
2020
export * from './fileUtil'
2121
export * from './constants'
2222
export * from './resolveStreamUrl'
23+
export * from './resolveImageUrl'
2324
export * from './resolveUrlWithCascadingTimeout'
2425
export * from './stringUtils'
2526
export * from './challenges'

packages/mobile/src/components/audio/AudioPlayer.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useRef, useEffect, useCallback, useState, useMemo } from 'react'
22

33
import { useCurrentUserId, useTracks, useUsers } from '@audius/common/api'
44
import { useCurrentTrack } from '@audius/common/hooks'
5-
import { ErrorLevel, Feature, Name } from '@audius/common/models'
5+
import { ErrorLevel, Feature, Name, SquareSizes } from '@audius/common/models'
66
import type { ID, Track } from '@audius/common/models'
77
import {
88
libraryPageTracksLineupActions,
@@ -25,6 +25,7 @@ import {
2525
Genre,
2626
removeNullable,
2727
getTrackPreviewDuration,
28+
resolveImageUrl,
2829
resolveStreamUrl
2930
} from '@audius/common/utils'
3031
import type { Nullable } from '@audius/common/utils'
@@ -67,6 +68,16 @@ import { useSavePodcastProgress } from './useSavePodcastProgress'
6768
export const DEFAULT_IMAGE_URL =
6869
'https://download.audius.co/static-resources/preview-image.jpg'
6970

71+
const TRACK_ARTWORK_PREFERRED_SIZES = [
72+
SquareSizes.SIZE_1000_BY_1000,
73+
SquareSizes.SIZE_480_BY_480,
74+
SquareSizes.SIZE_150_BY_150
75+
] as const
76+
77+
const getArtworkTargetSize = (artwork?: Track['artwork']) =>
78+
TRACK_ARTWORK_PREFERRED_SIZES.find((size) => artwork?.[size]) ??
79+
SquareSizes.SIZE_1000_BY_1000
80+
7081
const { getPlaying, getSeek, getCounter, getPlaybackRate, getUid } =
7182
playerSelectors
7283
const { setTrackPosition } = playbackPositionActions
@@ -351,7 +362,11 @@ export const AudioPlayer = () => {
351362

352363
const imageUrl =
353364
localTrackImageSource ??
354-
track.artwork['1000x1000'] ??
365+
(await resolveImageUrl({
366+
artwork: track.artwork,
367+
targetSize: getArtworkTargetSize(track.artwork),
368+
defaultImage: DEFAULT_IMAGE_URL
369+
})) ??
355370
DEFAULT_IMAGE_URL
356371

357372
return {

0 commit comments

Comments
 (0)