doublesymmetry / react-native-track-player

A fully fledged audio module created for music apps. Provides audio playback, external media controls, background mode and more!
https://rntp.dev/
Apache License 2.0
3.18k stars 981 forks source link

fix(android): resolve asset #2194

Closed lovegaoshi closed 3 months ago

lovegaoshi commented 8 months ago

since appcenter is being depreciated next year all the below context is no longer relevant

I have a problem where on android, after I deployed codepush, the custom icons in the notification area would fail to resolve and revert back to the default icons. While i'm not sure if this line fixes my codepush issue, I saw https://github.com/doublesymmetry/react-native-track-player/issues/2101 and https://github.com/doublesymmetry/react-native-track-player/issues/2188 which might be a related asset resolving problem, and from a glance the example app's pure(demo) works again. @puckey i have no idea how resolveAssetSource works

might fix https://github.com/doublesymmetry/react-native-track-player/issues/2101 might fix https://github.com/doublesymmetry/react-native-track-player/issues/2188


after some stupidity I realized I thought my line works but its bc my metro is somehow caching build results - no wonder why i built in 3 seconds. After some frustrations I found out the return type of locally imported assets must be {uri: string} to work in android (still unsure what caused my particular codepush issue, or if custom icon is failing as a result), but not in <Image>.

I think Track.artwork needs to be string | assetResource (?) for ts type annotation, but its a TODO now

lovegaoshi commented 8 months ago

just did a release build on my app with this fix, notif area custom icon doesnt break; probably trying out codepush later

lovegaoshi commented 8 months ago

seems to also fix https://github.com/doublesymmetry/react-native-track-player/issues/2103 because updateMetadataForTrack, updateNowPlayingMetadata both uses resolveImportedAssetOrPath

lovegaoshi commented 8 months ago

unfortunately no it doesnt fix the codepushed asset resolve custom icons:( but a typical <Image>'s asset is fine updated from codepush.

andordavoti commented 7 months ago

This fixed my issue where Android prod didn't play audio. Thanks a lot for the help:)

itsramiel commented 6 months ago

@lovegaoshi Do you have any insights as to why it before your change it was working on debug but not release? The change fixes it for me but I am curious why?

itsramiel commented 6 months ago

@dcvz could you please take a look? Not loading a local file in release is definitely a bug

lovegaoshi commented 6 months ago

in dev imported sources is bundled a 8081 "weblink“ so this string is queried as an web address without a problem; in release this is a number representing the bundled resources and exoplayer needs the uri identifier to specify it thats my guess. my other problem is what happens when codepush comes into play - it seems to work for some bundled resources but not others (specifically notification manager icons)

On Tue, Dec 26, 2023 at 11:45 PM Rami Elwan @.***> wrote:

@lovegaoshi https://github.com/lovegaoshi Do you have any insights as to why it before your change it was working on debug but not release? The change fixes it for me but I am curious why?

— Reply to this email directly, view it on GitHub https://github.com/doublesymmetry/react-native-track-player/pull/2194#issuecomment-1870038387, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZMOVVU7JV5LCHUKJHODUOTYLPGYXAVCNFSM6AAAAAA63RQU4SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZQGAZTQMZYG4 . You are receiving this because you were mentioned.Message ID: @.*** com>

jmarsh24 commented 3 months ago

I just ran into this issue on android after the android simulator worked and iOS fully works. sourcing my react native track player package from this repo fixed the issue. This PR seems to be working but has not been merged to master. I'm commenting to acknowledge that this has been tested and is working in production.

Please merge for others.

dcvz commented 3 months ago

not sure why this slipped my radar, thanks for this @lovegaoshi! will merge and make a 4.1.1