TrackPlayer.load does not accept artwork: ResourceObject and crashes
Describe the Bug
The function load does not accept a Track object with its artwork field defined as a ResourceObject.
Steps To Reproduce
- Clone this ready-made repository to reproduce the error
- In file
App.js, comment lines93-96, uncomment lines98-101and113 - Run app
Code To Reproduce
await TrackPlayer.load({
url: "https://files.freemusicarchive.org/storage-freemusicarchive-org/music/WFMU/Il_Sogno_Del_Marinaio/Live_on_Redundancy_Radio_with_DJ_Disk_Jockey_October_22_2014/Il_Sogno_Del_Marinaio_-_02_-_Partisian_Song.mp3",
title: "some title",
artist: "some artist",
duration: 3.01,
artwork: require("./assets/artwork.jpeg"), // causes a crash
});
Environment Info:
Paste the results of npx react-native info
❯ npx react-native info
info Fetching system and libraries information...
System:
OS: macOS 15.5
CPU: (10) arm64 Apple M1 Max
Memory: 911.75 MB / 64.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 23.6.0
path: /opt/homebrew/bin/node
Yarn:
version: 1.22.19
path: /opt/homebrew/bin/yarn
npm:
version: 10.9.2
path: /opt/homebrew/bin/npm
Watchman: Not Found
Managers:
CocoaPods:
version: 1.16.2
path: /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.4
- iOS 18.4
- macOS 15.4
- tvOS 18.4
- visionOS 2.4
- watchOS 11.4
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Xcode:
version: 16.3/16E140
path: /usr/bin/xcodebuild
Languages:
Java: Not Found
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli":
installed: 18.0.0
wanted: ^18.0.0
react:
installed: 19.0.0
wanted: 19.0.0
react-native:
installed: 0.79.1
wanted: 0.79.1
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: Not found
newArchEnabled: Not found
iOS:
hermesEnabled: true
newArchEnabled: true
info React Native v0.79.2 is now available (your project is running on v0.79.1).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.79.2
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.79.1&to=0.79.2
info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos".
Paste the exact react-native-track-player version you are using
^4.1.1
Real device? Or simulator?
real
What OS are you running?
iOS 18.4.1
How I can Help
- Fix
loadto acceptAddTrackinstead ofTrackOR - Update
TrackMetadataBaseto match:artwork?: string | ResourceObject;
its an easy fix on paper. TP.load doesnt use resolveImportedAssetOrPath like TP.add, so ud just have to do exactly taht
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.
PR here https://github.com/doublesymmetry/react-native-track-player/pull/2522