I used to work on the application, and I had a similar problem, and I was able to fix it, except that I did not broadcast audio. Hope this helps, you will need to change it for your purposes:
import android.media.AudioManager; import android.media.SoundPool; import android.media.SoundPool.OnLoadCompleteListener; import android.util.SparseIntArray;
Create sound effects and SparseIntArray Here I use sound files, you will have to change this part.
private static SoundPool soundPool; private static SparseIntArray soundPoolMap; public static final int S1 = R.raw.good_1, S2 = R.raw.bad_1, P1 = R.raw.power_1, P2 = R.raw.power_2, P3 = R.raw.power_3, P4 = R.raw.power_4, P5 = R.raw.power_5, WIN = R.raw.round_win;
Initialize your sounds and add them to the card
public static void initSounds(Context context) { soundPool = new SoundPool(2, AudioManager.STREAM_MUSIC, 100); soundPoolMap = new SparseIntArray(8); soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() { public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { loaded = true; } }); soundPoolMap.put(S1, soundPool.load(context, R.raw.good_1, 1)); soundPoolMap.put(S2, soundPool.load(context, R.raw.bad_1, 2)); soundPoolMap.put(P1, soundPool.load(context, R.raw.power_1, 3)); soundPoolMap.put(P2, soundPool.load(context, R.raw.power_2, 4)); soundPoolMap.put(P3, soundPool.load(context, R.raw.power_3, 5)); soundPoolMap.put(P4, soundPool.load(context, R.raw.power_4, 6)); soundPoolMap.put(P5, soundPool.load(context, R.raw.power_5, 7)); soundPoolMap.put(WIN, soundPool.load(context, R.raw.round_win, 8)); }
Play sound
public static void playSound(Context context, int soundID) { float volume = 1; if(soundPool == null || soundPoolMap == null) { initSounds(context); } soundPool.play(soundPoolMap.get(soundID), volume, volume, 1, 0, 1f); }
Example: playSound (this, P1);
What happens, I use the SoundPool class and then display the audio streams using SparseIntArray