我正在使用此方法播放资源中的声音
public void PlaySound(String sound_name) {
try {
if (mPlayer != null) {
if (mPlayer.isPlaying()) {
mPlayer.stop();
}
mPlayer.release();
}
mPlayer = new MediaPlayer();
int timerSoundId;
String packageName = getPackageName();
timerSoundId = getResources().getIdentifier( sound_name , "raw" , packageName );
AssetFileDescriptor descriptor = getResources().openRawResourceFd(timerSoundId);
mPlayer.setDataSource(descriptor.getFileDescriptor(), descriptor.getStartOffset(), descriptor.getLength());
descriptor.close();
mPlayer.prepare();
mPlayer.setVolume(1f, 1f);
mPlayer.start();
} catch (Exception e) {
}
}
当我在设备上测试应用程序时,无论何时播放声音都会打印此错误
07-19 11:21:55.715 1833-6093/? E/AudioPolicyService: getOutput() tid 6093 ++
07-19 11:21:55.715 1833-6093/? E/AudioPolicyService: getOutput() tid 6093 --
07-19 11:21:55.715 1833-6093/? E/AudioPolicyService: getOutput() tid 6093 ++
07-19 11:21:55.715 1833-6093/? E/AudioPolicyService: getOutput() tid 6093 --
07-19 11:21:55.715 1833-6093/? E/AudioPolicyService: getOutput() tid 6093 ++
07-19 11:21:55.715 1833-6093/? E/AudioPolicyService: getOutput() tid 6093 --
07-19 11:21:55.715 1833-6093/? E/AudioPolicyService: getOutput() tid 6093 ++
07-19 11:21:55.715 1833-6093/? E/AudioPolicyService: getOutput() tid 6093 --
07-19 11:21:55.715 1833-6093/? E/AudioPolicyManagerBase: unknown stream type
07-19 11:21:55.715 1833-6093/? E/AudioPolicyManagerBase: unknown stream type
07-19 11:21:55.715 1833-6093/? E/AudioPolicyManagerBase: unknown stream type
07-19 11:21:55.715 1833-6093/? E/AudioPolicyManagerBase: unknown stream type
07-19 11:21:55.715 1833-6093/? E/AudioPolicyManagerBase: unknown stream type
07-19 11:21:55.715 1833-6093/? E/AudioPolicyManagerBase: unknown stream type
07-19 11:21:55.715 1833-6093/? E/AudioPolicyManagerBase: unknown stream type
07-19 11:21:55.715 1833-6093/? E/AudioPolicyManagerBase: unknown stream type
07-19 11:21:55.715 1833-6093/? E/AudioPolicyManagerBase: unknown stream type
07-19 11:21:55.715 1833-6093/? E/AudioPolicyManagerBase: unknown stream type
应用程序没有崩溃,我无法检测到任何问题。我认为原因将是音频文件的格式。他们是wav。但后来我把它们改成了mp3,仍然没什么区别。音乐播放,但留下了这些日志行。
我要担心吗?或者只是忽略它? 任何建议将不胜感激......