【发布时间】:2020-11-11 17:07:30
【问题描述】:
我尝试使用调试模式在我的设备中播放音乐,但即使文件正确也无法播放,代码如下:
在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
【问题讨论】:
-
你有什么解决办法吗?
标签: javascript react-native android-studio