我正在使用这种方法在我的资产中播放声音
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,还是没有区别。音乐播放,但将这些 Log 行留在后面。
我需要担心吗?还是直接忽略?任何建议将不胜感激...