2010-10-11 5 views
3

Я использую MediaPlayer для воспроизведения некоторых звуковых файлов, которые иногда перекрываются. Я замечаю, что в окне LogCat я продолжаю получать это сообщение:Ошибка при воспроизведении медиафайлов

экземпляры android max компонента OMX.TI.ACC. Декодирование уже создано.

Похоже, что это не влияет на мое приложение, так как звуки продолжают играть очень хорошо. Кто-нибудь знает, что означает это сообщение, и мне нужно беспокоиться об этом?

ответ

0

SoundPool может быть лучшим вариантом для воспроизведения нескольких коротких звуков.

Создание Soundpool

public static final int SOUND_1 = 1; 
public static final int SOUND_2 = 2; 

SoundPool mSoundPool; 
HashMap<Integer, Integer> mHashMap; 

@Override 
public void onCreate(Bundle savedInstanceState){ 
    mSoundPool = new SoundPool(2, AudioManager.STREAM_MUSIC, 100); 
    mSoundMap = new HashMap<Integer, Integer>(); 

    if(mSoundPool != null){ 
     mSoundMap.put(SOUND_1, mSoundPool.load(this, R.raw.sound1, 1)); 
     mSoundMap.put(SOUND_2, mSoundPool.load(this, R.raw.sound2, 1)); 
    } 
} 

Затем воспроизводить звук с помощью вызова пользовательской функции.

Воспроизведение звука

/* 
*Call this function from code with the sound you want e.g. playSound(SOUND_1); 
*/ 
public void playSound(int sound) { 
    AudioManager mgr = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE); 
    float streamVolumeCurrent = mgr.getStreamVolume(AudioManager.STREAM_MUSIC); 
    float streamVolumeMax = mgr.getStreamMaxVolume(AudioManager.STREAM_MUSIC); 
    float volume = streamVolumeCurrent/streamVolumeMax; 

    if(mSoundPool != null){ 
     mSoundPool.play(mSoundMap.get(sound), volume, volume, 1, 0, 1.0f); 
    } 
} 
Смежные вопросы