在尝试了SO的无数变化之后,我仍然无法使它工作。你能告诉我我的设置有什么问题吗?我试图让媒体播放器通过耳机播放。
我在清单
中设置了权限 <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
这是在媒体文件的start()之前调用的方法:
private void setMediaResources() {
AudioManager am = (AudioManager) getActivity().getSystemService(
Context.AUDIO_SERVICE);
am.setMode(AudioManager.MODE_IN_CALL);
am.setSpeakerphoneOn(true);
mDialTone = MediaPlayer.create(getActivity(), R.raw.dial_tone_0_5);
mDialTone.setAudioStreamType(AudioManager.MODE_IN_CALL);
mDialTone2 = MediaPlayer.create(getActivity(), R.raw.dial_tone_0_5);
mDialTone2.setAudioStreamType(AudioManager.MODE_IN_CALL);
mVoice = MediaPlayer.create(getActivity(), R.raw.papa_noel_english);
mVoice.setAudioStreamType(AudioManager.MODE_IN_CALL);
}
日志:
08-07 10:36:45.814: W/MediaPlayer(14667): info/warning (973, 0)
08-07 10:36:45.814: E/MediaPlayer(14667): setAudioStream called in state 8
08-07 10:36:45.814: E/MediaPlayer(14667): error (-38, 0)
08-07 10:36:45.824: W/MediaPlayer(14667): info/warning (973, 0)
08-07 10:36:45.824: E/MediaPlayer(14667): setAudioStream called in state 8
08-07 10:36:45.824: E/MediaPlayer(14667): error (-38, 0)
08-07 10:36:45.859: W/MediaPlayer(14667): info/warning (973, 0)
08-07 10:36:45.859: E/MediaPlayer(14667): setAudioStream called in state 8
08-07 10:36:45.859: E/MediaPlayer(14667): error (-38, 0)
08-07 10:36:45.859: E/MediaPlayer(14667): start called in state 0
08-07 10:36:45.859: E/MediaPlayer(14667): error (-38, 0)
08-07 10:36:45.869: I/Choreographer(14667): Skipped 35 frames! The application may be doing too much work on its main thread.
08-07 10:36:45.974: I/MediaPlayer(14667): Info (973,0)
08-07 10:36:45.974: I/MediaPlayer(14667): Don't send intent. msg.arg1 = 0, msg.arg2 = 0
08-07 10:36:45.974: E/MediaPlayer(14667): Error (-38,0)
08-07 10:36:45.974: E/MediaPlayer(14667): start called in state 0
08-07 10:36:45.974: E/MediaPlayer(14667): error (-38, 0)
08-07 10:36:45.974: I/MediaPlayer(14667): Info (973,0)
08-07 10:36:45.974: I/MediaPlayer(14667): Don't send intent. msg.arg1 = 0, msg.arg2 = 0
08-07 10:36:45.974: E/MediaPlayer(14667): Error (-38,0)
08-07 10:36:45.974: E/MediaPlayer(14667): start called in state 0
08-07 10:36:45.974: E/MediaPlayer(14667): error (-38, 0)
08-07 10:36:45.974: I/MediaPlayer(14667): Info (973,0)
08-07 10:36:45.979: I/MediaPlayer(14667): Don't send intent. msg.arg1 = 0, msg.arg2 = 0
08-07 10:36:45.979: E/MediaPlayer(14667): Error (-38,0)
08-07 10:36:46.289: E/MediaPlayer(14667): Error (-38,0)
08-07 10:36:46.289: E/MediaPlayer(14667): start called in state 0
08-07 10:36:46.289: E/MediaPlayer(14667): error (-38, 0)
08-07 10:36:46.289: E/MediaPlayer(14667): Error (-38,0)
08-07 10:36:46.289: E/MediaPlayer(14667): start called in state 0
08-07 10:36:46.289: E/MediaPlayer(14667): error (-38, 0)
08-07 10:36:46.289: E/MediaPlayer(14667): Error (-38,0)
08-07 10:36:46.344: E/MediaPlayer(14667): Error (-38,0)
08-07 10:36:46.344: E/MediaPlayer(14667): start called in state 0
08-07 10:36:46.344: E/MediaPlayer(14667): error (-38, 0)
08-07 10:36:46.344: E/MediaPlayer(14667): Error (-38,0)
08-07 10:36:46.344: E/MediaPlayer(14667): Error (-38,0)
08-07 10:36:59.509: E/MediaPlayer(14667): stop called in state 0
08-07 10:36:59.509: E/MediaPlayer(14667): error (-38, 0)
08-07 10:36:59.509: E/MediaPlayer(14667): stop called in state 0
08-07 10:36:59.509: E/MediaPlayer(14667): error (-38, 0)
08-07 10:36:59.509: E/MediaPlayer(14667): stop called in state 0
08-07 10:36:59.509: E/MediaPlayer(14667): error (-38, 0)