我有一段代码在某些设备(Samsung Galaxy S2、Acer A510)上运行良好,但在其他设备(HTC One S)上却导致 MediaPlayer 崩溃。导致问题的代码:
if(file.exists()) {
mediaPlayer = MediaPlayer.create(this, Uri.fromFile(file));
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setVolume(100, 100);
mediaPlayer.start();
};
我尝试在 onPrepared 回调或其他创建 mediaPlayer 的方式中启动它。它们都可以在 HTC 以外的任何设备上正常工作。日志错误:
06-20 15:33:13.810: W/AudioSystem(6021): AudioFlinger server died!
06-20 15:33:13.810: W/IMediaDeathNotifier(6021): media server died
06-20 15:33:13.810: E/MediaPlayer(6021): error (100, 0)
06-20 15:33:13.810: E/MediaPlayer(6021): Mediaserver died in 16 state
06-20 15:33:13.820: I/ServiceManager(6021): Waiting for service media.audio_flinger...
06-20 15:33:14.821: E/MediaPlayer(6021): Error (100,0)
如果有人有任何建议,我将不胜感激。