我正在使用超级功能的sdk播放音频文件。
为此,我使用player->open("/storage/emulated/0/0567894638.mp3");
我还添加了权限READ_EXTERNAL_STORAGE。
问题是,没有显示错误,但不能播放文件。
如果我从资产中获取了相同的文件,则说明文件已成功播放。
请有人告诉我我对内部存储的播放有哪些更改?
最佳答案
String file_path = "/storage/emulated/0/kal.mp3";
File f = new File("" + file_path);
fileLength = (int) f.length();
Pair<Integer, Integer> deviceAudioInfo = getDeviceAudioInfo();
Integer sampleRate = deviceAudioInfo.first;
Integer bufferSize = deviceAudioInfo.second;
SuperpoweredExample(sampleRate, bufferSize, file_path, 0, fileLength);
SuperpoweredExample::SuperpoweredExample(unsigned int samplerate, unsigned int buffersize,
const char *path, int fileOffset, int fileLength) : volume(1.0f * headroom) {
stereoBuffer = (float *) memalign(16, (buffersize + 16) * sizeof(float) * 2);
player = new SuperpoweredAdvancedAudioPlayer(&player, NULL, samplerate, 0);
player->open(path);
audioSystem = new SuperpoweredAndroidAudioIO(samplerate, buffersize, false, true,
audioProcessing,
this, -1, SL_ANDROID_STREAM_MEDIA, buffersize * 2);
}
添加权限READ_EXTERNAL_STORAGE