我正在尝试使用调试模式在我的设备上播放音乐,但即使文件是正确的,它也不能播放,代码如下:
在componentDidMount中初始化播放器:
componentDidMount() {
this.requestPermission();
this.init_player();
}
init_player = async () => {
await TrackPlayer.setupPlayer();
await TrackPlayer.add({
id: "1",
url: "file:///storage/emulated/0/Download/Maluma-Hawai.mp3",
title: "Dfdf",
artist: "Dfdf",
});
}然后在按钮中只需调用该方法:
TrackPlayer.play()
但是它不工作,在file://+path和file:///+path上尝试过
我使用的是android X
跟踪播放器gitbuh:music player
发布于 2021-10-11 09:45:36
这首歌很适合我:我先下载了一首曲目到DocumentDirectoryPath上。然后,我可以向url添加以下内容:
url: `file://${DocumentDirectoryPath}/GetLucky.m4a`版本:"react-native-track-player":"^2.0.1",
https://stackoverflow.com/questions/64790953
复制相似问题