List of usage examples for android.media AudioManager STREAM_ALARM
int STREAM_ALARM
To view the source code for android.media AudioManager STREAM_ALARM.
Click Source Link
From source file:com.ieeton.agency.activity.ChatActivity.java
private void playSound() { AudioManager mAudioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE); int curVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_ALARM); if (curVolume == 0) { return;/*from w w w . j a v a 2 s . c om*/ } mStreamID = mSoundPool.play(mSoundID, curVolume, curVolume, 0, 0, 1); }
From source file:com.example.mydemos.view.RingtonePickerActivity.java
@Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long id) { Log.e("lys", "onItemClick position ==" + position + "id" + id); if (id == -1) { if (mHasSilentItem) { if ((mHasDefaultItem && (position == 1)) || !mHasDefaultItem) { Log.e("lys", "onItemClick silentItemChecked == true"); //toneCur.moveToPosition(position); mSelectedId = SILENT_ID; mSelectedUri = null;// w w w. java 2 s. c o m silentItemChecked = true; defaultItemChecked = false; stopMediaPlayer(); listView.invalidateViews(); return; } else if (mHasDefaultItem && (position == 0)) { Log.e("lys", "onItemClick defaultItemChecked == true"); //toneCur.moveToPosition(position); mSelectedId = DEFAULT_ID; mSelectedUri = mUriForDefaultItem; defaultItemChecked = true; silentItemChecked = false; } } else { if (mHasDefaultItem) { Log.e("lys", "onItemClick defaultItemChecked == true"); //toneCur.moveToPosition(position); mSelectedId = DEFAULT_ID; mSelectedUri = mUriForDefaultItem; defaultItemChecked = true; silentItemChecked = false; } } } else { if (mHasSilentItem) { silentItemChecked = false; position--; } if (mHasDefaultItem) { defaultItemChecked = false; position--; } } if (id != -1) { toneCur.moveToPosition(position); Log.e("lys", "onItemClick position == " + position + "id ==" + id); long newId = toneCur.getLong(toneCur.getColumnIndex(MediaStore.Audio.Media._ID)); mSelectedId = newId; Log.e("lys", " onItemClick mSelectedId==" + mSelectedId); //wuqingliang modify begin20130307 if (tabName == SYSTEM_TONE) { BaseUri = MediaStore.Audio.Media.INTERNAL_CONTENT_URI; Log.e("lys", "BaseUri = MediaStore.Audio.Media.INTERNAL_CONTENT_URI;111111"); } else { BaseUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; Log.e("lys", "BaseUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;1111111"); } //wuqingliang modify end mSelectedUri = ContentUris.withAppendedId(BaseUri, newId); } listView.invalidateViews(); audioManager.requestAudioFocus(mAudioFocusListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT); stopMediaPlayer(); mMediaPlayer = new MediaPlayer(); try { if (toneType == ALARM_TYPE) mMediaPlayer.setAudioStreamType(AudioManager.STREAM_ALARM); else mMediaPlayer.setAudioStreamType(AudioManager.STREAM_RING); mMediaPlayer.setDataSource(RingtonePickerActivity.this, mSelectedUri); mMediaPlayer.prepare(); mMediaPlayer.start(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.ieeton.user.activity.ChatActivity.java
private void playSound() { AudioManager mAudioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE); int curVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_ALARM); if (curVolume == 0) { return;/*from ww w. ja va2 s. c o m*/ } mSoundPool.play(mSoundID, curVolume, curVolume, 0, 0, 1); }
From source file:com.almalence.plugins.capture.video.VideoCapturePlugin.java
protected void muteAllSounds() { ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_ALARM, true); ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_DTMF, true); ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_MUSIC, true); ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_NOTIFICATION, true); ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_RING, true); ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_SYSTEM, true); ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_VOICE_CALL, true); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_ALARM, 0, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_DTMF, 0, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_RING, 0, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_SYSTEM, 0, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_VOICE_CALL, 0, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).adjustStreamVolume(AudioManager.STREAM_ALARM, AudioManager.ADJUST_MUTE, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).adjustStreamVolume(AudioManager.STREAM_DTMF, AudioManager.ADJUST_MUTE, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_MUTE, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).adjustStreamVolume(AudioManager.STREAM_RING, AudioManager.ADJUST_MUTE, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).adjustStreamVolume(AudioManager.STREAM_SYSTEM, AudioManager.ADJUST_MUTE, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).adjustStreamVolume(AudioManager.STREAM_VOICE_CALL, AudioManager.ADJUST_MUTE, 0); }
From source file:com.almalence.plugins.capture.video.VideoCapturePlugin.java
protected void unmuteAllSounds() { ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_ALARM, false); ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_DTMF, false); ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_MUSIC, false); ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_NOTIFICATION, false); ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_RING, false); ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_SYSTEM, false); ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_VOICE_CALL, false); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_ALARM, 0, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_DTMF, 0, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_RING, 0, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_SYSTEM, 0, 0); }
From source file:org.thecongers.mcluster.MainActivity.java
public void speakString(String speech) { HashMap<String, String> myHashAlarm = new HashMap(); myHashAlarm.put(TextToSpeech.Engine.KEY_PARAM_STREAM, String.valueOf(AudioManager.STREAM_ALARM)); text2speech.speak(speech, TextToSpeech.QUEUE_FLUSH, myHashAlarm); }
From source file:com.nest5.businessClient.Initialactivity.java
public void playSound(Context context) throws IllegalArgumentException, SecurityException, IllegalStateException, IOException { Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); MediaPlayer mMediaPlayer = new MediaPlayer(); mMediaPlayer.setDataSource(context, soundUri); final AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); if (audioManager.getStreamVolume(AudioManager.STREAM_ALARM) != 0) { mMediaPlayer.setAudioStreamType(AudioManager.STREAM_ALARM); mMediaPlayer.setLooping(false);/* www . j a v a 2 s .c o m*/ mMediaPlayer.prepare(); mMediaPlayer.start(); } }