SoundPoolとMediaPlayer
を使用してゲームを開発し、オーディオサウンドを再生しています。音声が再生されるたびに、LogCatにエラーが表示されます。私はSoundPoolを使用する場合、同じ問題が発生したgetAudioMode [0]エラー
05-31 15:02:56.400: ERROR/AudioTrack(2384): getAudioMode[0]
05-31 15:02:56.400: ERROR/AudioR2VS(2384): The 11025 sample rate is not supported by R2VS solution.
:
public class MusicSoundResources {
private static final String CLASS_TAG = "SoundResources";
private static MusicSoundResources _instance;
public static HashMap<String, MediaPlayer> mSoundPoolMap;
private static AudioManager mAudioManager;
private static Context mContext;
public MusicSoundResources() {
}
public static void initSounds(Context theContext) {
mContext = theContext;
mSoundPoolMap = new HashMap<String, MediaPlayer>();
mAudioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
loadSounds();
}
private static void loadSounds() {
mSoundPoolMap.put("swallowed", MediaPlayer.create(mContext, R.raw.swallowed));
}
public static void playSound(String soundTrackIndex, boolean loop) {
MediaPlayer mediaPlayer = mSoundPoolMap.get(soundTrackIndex);
float streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
streamVolume = streamVolume/mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
mediaPlayer.setVolume(streamVolume, streamVolume);
mediaPlayer.setLooping(loop);
mediaPlayer.start();
}
}
これらは、ディスプレイの2つのログです。
サポートされているサンプルレートを教えてください。
コードの一部を表示します。 –
@Lukas Knuth:SoundPool mSoundPool =新しいSoundPool(50、AudioManager.STREAM_MUSIC、0); HashMap mSoundPoolMap =新しいHashMap (); mSoundPoolMap.put( "fire"、mSoundPool.load(mContext、R.raw.fire、1)); mSoundPool.play(mSoundPoolMap.get( "fire")、streamVolume、streamVolume、1、0、1); –
Nuraiz
あなたの投稿を編集したはずです...私はあなたのためにそれをしました。 –