特定の期間、サウンドファイルを同時に再生したいというAndroidメディアアプリケーションを使用しています。クラスを作成し、このクラス内で概念を使用SoundPool
しThread
てサウンドを再生していますが、アプリケーションを実行すると、ANR 状態になり、log-cat に警告が表示されます
サンプル 2130968576 準備ができていません
誰でもこれを修正するのを手伝ってください...
クラス
package com.kodspider.funk;
import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;
public class CustomPlayer implements Runnable{
int song_id;
long time;
int button_id;
Context ctx;
SoundPool soundpool;
public CustomPlayer(int s_id, long Time, Context ct){
song_id = load(ctx, s_id, 0);
time = Time;
ctx = ct;
}
public void run(){
long start = System.currentTimeMillis();
System.out.println("set_time:"+time+"Song_id:"+song_id+"current_time:"+start);
long end = start + time;
while (System.currentTimeMillis() < end){
//Initialization
soundpool = new SoundPool(8, AudioManager.STREAM_MUSIC, 0);
soundpool.play(song_id, 1.0f, 1.0f, 1, -1, 1.0f);
}
}
public int load (Context context, int resId, int priority){
return resId;
}
}
ログキャット
07-07 10:57:51.828: I/ApplicationPackageManager(13625): cscCountry is not German : INS
07-07 10:57:57.656: I/ApplicationPackageManager(13625): cscCountry is not German : INS
07-07 10:57:59.343: W/KeyCharacterMap(13625): Can't open keycharmap file
07-07 10:57:59.343: W/KeyCharacterMap(13625): Error loading keycharmap file
07-07 10:57:59.343: W/KeyCharacterMap(13625): Using default keymap
07-07 10:58:44.820: I/ApplicationPackageManager(13625): cscCountry is not German : INS
07-07 10:58:49.718: I/System.out(13625): TAG------->60000---->2130968576
07-07 10:58:49.726: W/SoundPool(13625): sample 2130968576 not READY