List of usage examples for android.media AudioManager STREAM_SYSTEM
int STREAM_SYSTEM
To view the source code for android.media AudioManager STREAM_SYSTEM.
Click Source Link
From source file:com.ferdi2005.secondgram.NotificationsController.java
private void playInChatSound() { if (!inChatSoundEnabled || MediaController.getInstance().isRecordingAudio()) { return;/*from w w w. j a va2 s . c o m*/ } try { if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) { return; } } catch (Exception e) { FileLog.e(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; } 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) { try { soundPool.play(sampleId, 1.0f, 1.0f, 1, 0, 1.0f); } catch (Exception e) { FileLog.e(e); } } } }); } if (soundIn == 0 && !soundInLoaded) { soundInLoaded = true; soundIn = soundPool.load(ApplicationLoader.applicationContext, R.raw.sound_in, 1); } if (soundIn != 0) { try { soundPool.play(soundIn, 1.0f, 1.0f, 1, 0, 1.0f); } catch (Exception e) { FileLog.e(e); } } } catch (Exception e) { FileLog.e(e); } } }); } catch (Exception e) { FileLog.e(e); } }
From source file:ir.besteveryeverapp.telegram.NotificationsController.java
public void playOutChatSound() { if (!inChatSoundEnabled || MediaController.getInstance().isRecordingAudio() || NightModeUtil.blockSound()) { return;/* ww w. j a v a 2s.c om*/ } 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(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("tmessages", e); } } }); }
From source file:com.ferdi2005.secondgram.NotificationsController.java
public void playOutChatSound() { if (!inChatSoundEnabled || MediaController.getInstance().isRecordingAudio()) { return;/*ww w. j av a 2 s. co m*/ } try { if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) { return; } } catch (Exception e) { FileLog.e(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) { try { soundPool.play(sampleId, 1.0f, 1.0f, 1, 0, 1.0f); } catch (Exception e) { FileLog.e(e); } } } }); } if (soundOut == 0 && !soundOutLoaded) { soundOutLoaded = true; soundOut = soundPool.load(ApplicationLoader.applicationContext, R.raw.sound_out, 1); } if (soundOut != 0) { try { soundPool.play(soundOut, 1.0f, 1.0f, 1, 0, 1.0f); } catch (Exception e) { FileLog.e(e); } } } catch (Exception e) { FileLog.e(e); } } }); }