List of usage examples for android.media SoundPool load
public int load(Context context, int resId, int priority)
From source file:com.xlythe.engine.theme.Theme.java
public static int getSound(Context context, SoundPool soundPool, Res res) { int id = getId(context, res.getType(), res.getName()); if (id == 0) { id = context.getResources().getIdentifier(res.getName(), res.getType(), context.getPackageName()); return soundPool.load(context, id, 1); }/*w ww . j av a2 s .c o m*/ return soundPool.load(getThemeContext(context), id, 1); }
From source file:org.peaklabs.consumer.Escanea.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Initialize and start the bar code recognition. initializeAndStartBarcodeScanning(); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle(getResources().getString(R.string.scan)); soundpool = new SoundPool(5, AudioManager.STREAM_NOTIFICATION, 0); soundpool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() { public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { loaded = true;// www .j av a 2 s . com } }); idBeep = soundpool.load(this, R.raw.beep, 1); }
From source file:com.kentli.cycletrack.RecordingService.java
@Override public void onCreate() { super.onCreate(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { AudioAttributes attributes = new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_GAME) .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION).build(); soundpool = new SoundPool.Builder().setAudioAttributes(attributes).build(); } else {/*from w ww .ja v a 2 s . c om*/ soundpool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0); } soundpool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() { @Override public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { soundPool.play(sampleId, 1.0f, 1.0f, 0, 0, 1.0f); } }); bikebell = soundpool.load(this.getBaseContext(), R.raw.bikebell, 1); }
From source file:com.intel.xdk.notification.Notification.java
@Override public void initialize(CordovaInterface cordova, CordovaWebView webView) { super.initialize(cordova, webView); //get convenience reference to activity activity = cordova.getActivity();//from www.j av a 2s. c om //init sounds soundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 100); //this is needed so that the sound plays the first time soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() { public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { if (beepCount != -1 && soundPool == Notification.this.soundPool && sampleId == SOUND_BEEP && status == 0) { beep(beepCount); } } }); //SOUND_BEEP = soundPool.load(activity, R.raw.beep, 1); SOUND_BEEP = soundPool.load(activity, activity.getResources().getIdentifier("xdkbeep", "raw", activity.getPackageName()), 1); }
From source file:com.b44t.messenger.NotificationsController.java
public void playOutChatSound() { if (!inChatSoundEnabled || MediaController.getInstance().isRecordingAudio()) { return;/*from w ww .ja va2 s .c o m*/ } try { if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) { return; } } catch (Exception e) { FileLog.e("messenger", e); } notificationsQueue.postRunnable(new Runnable() { @Override public void run() { try { if (Math.abs(System.currentTimeMillis() - lastSoundOutPlay) <= 100) { return; } lastSoundOutPlay = System.currentTimeMillis(); if (soundPool == null) { soundPool = new SoundPool(3, AudioManager.STREAM_SYSTEM, 0); soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() { @Override public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { if (status == 0) { soundPool.play(sampleId, 1.0f, 1.0f, 1, 0, 1.0f); } } }); } if (soundOut == 0 && !soundOutLoaded) { soundOutLoaded = true; soundOut = soundPool.load(ApplicationLoader.applicationContext, R.raw.sound_out, 1); } if (soundOut != 0) { soundPool.play(soundOut, 1.0f, 1.0f, 1, 0, 1.0f); } } catch (Exception e) { FileLog.e("messenger", e); } } }); }
From source file:com.b44t.messenger.NotificationsController.java
private void playInChatSound() { if (!inChatSoundEnabled || MediaController.getInstance().isRecordingAudio()) { return;//ww w . j a va 2 s . c o m } try { if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) { return; } } catch (Exception e) { FileLog.e("messenger", e); } try { SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Context.MODE_PRIVATE); int notifyOverride = getNotifyOverride(preferences, opened_dialog_id); if (notifyOverride == 2) { return; } notificationsQueue.postRunnable(new Runnable() { @Override public void run() { if (Math.abs(System.currentTimeMillis() - lastSoundPlay) <= 500) { return; } lastSoundPlay = System.currentTimeMillis(); try { if (soundPool == null) { soundPool = new SoundPool(3, AudioManager.STREAM_SYSTEM, 0); soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() { @Override public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { if (status == 0) { soundPool.play(sampleId, 1.0f, 1.0f, 1, 0, 1.0f); } } }); } if (soundIn == 0 && !soundInLoaded) { soundInLoaded = true; soundIn = soundPool.load(ApplicationLoader.applicationContext, R.raw.sound_in, 1); } if (soundIn != 0) { soundPool.play(soundIn, 1.0f, 1.0f, 1, 0, 1.0f); } } catch (Exception e) { FileLog.e("messenger", e); } } }); } catch (Exception e) { FileLog.e("messenger", e); } }
From source file:org.telegram.messenger.NotificationsController.java
public void playOutChatSound() { if (!inChatSoundEnabled) { return;//from w w w .j av a 2 s . c o m } try { if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) { return; } } catch (Exception e) { FileLog.e("tmessages", e); } notificationsQueue.postRunnable(new Runnable() { @Override public void run() { try { if (lastSoundOutPlay > System.currentTimeMillis() - 100) { return; } lastSoundOutPlay = System.currentTimeMillis(); if (soundPool == null) { soundPool = new SoundPool(2, AudioManager.STREAM_SYSTEM, 0); soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() { @Override public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { if (status == 0) { soundPool.play(sampleId, 1.0f, 1.0f, 1, 0, 1.0f); } } }); } if (soundOut == 0 && !soundOutLoaded) { soundOutLoaded = true; soundOut = soundPool.load(ApplicationLoader.applicationContext, R.raw.sound_out, 1); } if (soundOut != 0) { soundPool.play(soundOut, 1.0f, 1.0f, 1, 0, 1.0f); } } catch (Exception e) { FileLog.e("tmessages", e); } } }); }
From source file:org.telegram.messenger.NotificationsController.java
private void playInChatSound() { if (!inChatSoundEnabled) { return;//from w w w . ja v a 2 s. co m } try { if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) { return; } } catch (Exception e) { FileLog.e("tmessages", e); } try { SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Context.MODE_PRIVATE); int notifyOverride = getNotifyOverride(preferences, openned_dialog_id); if (notifyOverride == 2) { return; } notificationsQueue.postRunnable(new Runnable() { @Override public void run() { if (lastSoundPlay > System.currentTimeMillis() - 500) { return; } try { if (soundPool == null) { soundPool = new SoundPool(2, AudioManager.STREAM_SYSTEM, 0); soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() { @Override public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { if (status == 0) { soundPool.play(sampleId, 1.0f, 1.0f, 1, 0, 1.0f); } } }); } if (soundIn == 0 && !soundInLoaded) { soundInLoaded = true; soundIn = soundPool.load(ApplicationLoader.applicationContext, R.raw.sound_in, 1); } if (soundIn != 0) { soundPool.play(soundIn, 1.0f, 1.0f, 1, 0, 1.0f); } } catch (Exception e) { FileLog.e("tmessages", e); } } }); } catch (Exception e) { FileLog.e("tmessages", e); } }
From source file:com.goftagram.telegram.messenger.NotificationsController.java
public void playOutChatSound() { if (!inChatSoundEnabled) { return;/*from w w w. java2s . c o m*/ } try { if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) { return; } } catch (Exception e) { FileLog.e("tmessages", e); } notificationsQueue.postRunnable(new Runnable() { @Override public void run() { try { if (Math.abs(System.currentTimeMillis() - lastSoundOutPlay) <= 100) { return; } lastSoundOutPlay = System.currentTimeMillis(); if (soundPool == null) { soundPool = new SoundPool(2, AudioManager.STREAM_SYSTEM, 0); soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() { @Override public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { if (status == 0) { soundPool.play(sampleId, 1.0f, 1.0f, 1, 0, 1.0f); } } }); } if (soundOut == 0 && !soundOutLoaded) { soundOutLoaded = true; soundOut = soundPool.load(ApplicationLoader.applicationContext, R.raw.sound_out, 1); } if (soundOut != 0) { soundPool.play(soundOut, 1.0f, 1.0f, 1, 0, 1.0f); } } catch (Exception e) { FileLog.e("tmessages", e); } } }); }
From source file:com.goftagram.telegram.messenger.NotificationsController.java
private void playInChatSound() { if (!inChatSoundEnabled) { return;//from w ww. j a v a2 s . com } try { if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) { return; } } catch (Exception e) { FileLog.e("tmessages", e); } try { SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Context.MODE_PRIVATE); int notifyOverride = getNotifyOverride(preferences, openned_dialog_id); if (notifyOverride == 2) { return; } notificationsQueue.postRunnable(new Runnable() { @Override public void run() { if (Math.abs(System.currentTimeMillis() - lastSoundPlay) <= 500) { return; } try { if (soundPool == null) { soundPool = new SoundPool(2, AudioManager.STREAM_SYSTEM, 0); soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() { @Override public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { if (status == 0) { soundPool.play(sampleId, 1.0f, 1.0f, 1, 0, 1.0f); } } }); } if (soundIn == 0 && !soundInLoaded) { soundInLoaded = true; soundIn = soundPool.load(ApplicationLoader.applicationContext, R.raw.sound_in, 1); } if (soundIn != 0) { soundPool.play(soundIn, 1.0f, 1.0f, 1, 0, 1.0f); } } catch (Exception e) { FileLog.e("tmessages", e); } } }); } catch (Exception e) { FileLog.e("tmessages", e); } }