最終更新:2016-05-26 (木) 18:36:16 (2884d)  

android.media.SoundPool
Top / android.media.SoundPool

短い音の再生をするときに使う。レイテンシが少し小さい。

http://developer.android.com/reference/android/media/SoundPool.html

メモ

  • 1つのインスタンスで複数の音声を再生することができる

メソッド

コンストラクタ

  • SoundPool(int maxStreams, int streamType, int srcQuality)
  • maxStreams:プールする最大の数
  • streamType:Streamのタイプ(通常はSTREAM_MUSICを利用する)
  • srcQuality:サンプリングレートのクオリティ
    • int: the priority of the sound. Currently has no effect. Use a value of 1 for future compatibility.

メモ

SoundPool.load

  • 読み込みは非同期で行われるため、loadメソッド直後に再生しようとすると再生できない場合があります。loadメソッド自体はすぐに応答を返すので要注意
  • Android2.2(API8)からは読み込み完了を知る手段(setOnLoadCompleteListener?でリスナを登録)もあります。
    int load (Context context, int resId, int priority)
  • 戻り値:a sound ID. This value can be used to play or unload the sound.

SoundPool.play

  • play(int soundID, float leftVolume, float rightVolume, int priority, int loop, float rate)

AOSP

  • AOSP/frameworks/base/media/java/android/media/SoundPool.java?

関連

参考