我正在使用React native开发音乐播放器,并且一直在使用package react-native-track-player。到目前为止,我在android中没有遇到问题。但是当我尝试在ios上运行它时出现错误
You attempted to set the key
0 with the value
{"id":"0",
"url":{"uri":"https://urltosong.mp3"},
"artwork":"https://url_to_artwork.jpg",
"artist":"author",
"title":"song titile"
}
on an object that is meant to be immutable and has been frozen.
产生错误的代码是
async function togglePlayback() {
const currentTrack = await TrackPlayer.getCurrentTrack();
if (currentTrack == null) {
await TrackPlayer.reset();
await TrackPlayer.add(playlist); //this was never adding and die silently
await TrackPlayer.play();
} else {
await TrackPlayer.add(playlist); //adding this line the error above appeared
await TrackPlayer.play();
//console.warn(TrackPlayer.getCurrentTrack())
}
}
我正在使用此版本的软件包"react-native-track-player": "^2.0.0-rc13",
我不知道我是否缺少什么。感谢您为解决此问题所提供的帮助。
答案 0 :(得分:0)
将曲目更改为此:
{"id":"0",
"url":"https://urltosong.mp3",
"artwork":"https://url_to_artwork.jpg",
"artist":"author",
"title":"song titile"
}
网址应为string
或Resource Object