public BeepManager(Activity activity) { activity.setVolumeControlStream(AudioManager.STREAM_MUSIC); // We do not keep a reference to the Activity itself, to prevent leaks this.context = activity.getApplicationContext(); }
public void updatePrefs() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); playBeep = shouldBeep(prefs, activity); if (playBeep && mediaPlayer == null) { // The volume on STREAM_SYSTEM is not adjustable, and users found it too loud, // so we now play on the music stream. activity.setVolumeControlStream(AudioManager.STREAM_MUSIC); mediaPlayer = buildMediaPlayer(activity); } }
private void initVideoView(Context ctx) { mContext = ctx; mVideoWidth = 0; mVideoHeight = 0; mVideoSarNum = 0; mVideoSarDen = 0; getHolder().addCallback(mSHCallback); setFocusable(true); setFocusableInTouchMode(true); requestFocus(); mCurrentState = STATE_IDLE; mTargetState = STATE_IDLE; if (ctx instanceof Activity) { ((Activity) ctx).setVolumeControlStream(AudioManager.STREAM_MUSIC); } }
public AndroidAudio (Context context, AndroidApplicationConfiguration config) { if (!config.disableAudio) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { AudioAttributes audioAttrib = new AudioAttributes.Builder() .setUsage(AudioAttributes.USAGE_GAME) .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) .build(); soundPool = new SoundPool.Builder().setAudioAttributes(audioAttrib).setMaxStreams(config.maxSimultaneousSounds).build(); }else { soundPool = new SoundPool(config.maxSimultaneousSounds, AudioManager.STREAM_MUSIC, 0);// srcQuality: the sample-rate converter quality. Currently has no effect. Use 0 for the default. } manager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE); if (context instanceof Activity) { ((Activity)context).setVolumeControlStream(AudioManager.STREAM_MUSIC); } } else { soundPool = null; manager = null; } }
public AndroidAudio (Context context, AndroidApplicationConfiguration config) { if (!config.disableAudio) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { AudioAttributes audioAttrib = new AudioAttributes.Builder() .setUsage(AudioAttributes.USAGE_GAME) .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) .build(); soundPool = new SoundPool.Builder().setAudioAttributes(audioAttrib).setMaxStreams(config.maxSimultaneousSounds).build(); }else { soundPool = new SoundPool(config.maxSimultaneousSounds, AudioManager.STREAM_MUSIC, 0);// srcQuality: the sample-rate converter quality. Currently has no effect. Use 0 for the default. } manager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE); if (context instanceof Activity) { ((Activity)context).setVolumeControlStream(AudioManager.STREAM_MUSIC); } } else { soundPool = null; manager = null; } }
@SuppressWarnings("deprecation") private void initVideoView(Context ctx) { mContext = ctx; mVideoWidth = 0; mVideoHeight = 0; getHolder().setFormat(PixelFormat.RGBA_8888); // PixelFormat.RGB_565 getHolder().addCallback(mSHCallback); // this value only use Hardware decoder before Android 2.3 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB && mHardwareDecoder) { getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } setFocusable(true); setFocusableInTouchMode(true); requestFocus(); mCurrentState = STATE_IDLE; mTargetState = STATE_IDLE; if (ctx instanceof Activity) ((Activity) ctx).setVolumeControlStream(AudioManager.STREAM_MUSIC); }
/** * @param streamType * @see android.app.Activity#setVolumeControlStream(int) */ public final void setVolumeControlStream(int streamType) { mActivity.setVolumeControlStream(streamType); }
public void enableVolumeControl(Activity activity) { if (activity != null) { activity.setVolumeControlStream(AudioManager.STREAM_MUSIC); } }
public void disableVolumeControl(Activity activity) { if (activity != null) { activity.setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE); } }
public GameView(Context context, Activity activity) { super(context); activity.setVolumeControlStream(AudioManager.STREAM_MUSIC); }
/** * Sets the volume control stream defined in preferences. */ static void setVolumeStream(Activity activity) { activity.setVolumeControlStream(getSelectedAudioStream(activity)); }
synchronized public void updatePrefs() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); playBeep = shouldBeep(prefs, activity); vibrate = prefs.getBoolean(PreferencesActivity.KEY_VIBRATE, false); if (playBeep && mediaPlayer == null) { // The volume on STREAM_SYSTEM is not adjustable, and users found it too loud, // so we now play on the music stream. activity.setVolumeControlStream(AudioManager.STREAM_MUSIC); mediaPlayer = buildMediaPlayer(activity); } }
private synchronized void updatePrefs() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); playBeep = shouldBeep(prefs, activity); vibrate = true; if (playBeep && mediaPlayer == null) { // The volume on STREAM_SYSTEM is not adjustable, and users found it // too loud, // so we now play on the music stream. activity.setVolumeControlStream(AudioManager.STREAM_MUSIC); mediaPlayer = buildMediaPlayer(activity); } }
private synchronized void updatePrefs() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); playBeep = shouldBeep(prefs, activity); vibrate = true; if (playBeep && mediaPlayer == null) { // The volume on STREAM_SYSTEM is not adjustable, and users found it // too loud, // so we now play on the music stream. activity.setVolumeControlStream(AudioManager.STREAM_MUSIC); mediaPlayer = buildMediaPlayer(activity); } }
private synchronized void updatePrefs() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); playBeep = shouldBeep(prefs, activity); vibrate = true; if (playBeep && mediaPlayer == null) { // The volume on STREAM_SYSTEM is not adjustable, and users found it // too loud, // so we now play on the music stream. activity.setVolumeControlStream(AudioManager.STREAM_MUSIC); mediaPlayer = buildMediaPlayer(activity); } }
synchronized void updatePrefs() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); playBeep = shouldBeep(prefs, activity); // vibrate = prefs.getBoolean(Preferences.KEY_VIBRATE, false); if (playBeep && mediaPlayer == null) { // The volume on STREAM_SYSTEM is not adjustable, and users found it too loud, // so we now play on the music stream. activity.setVolumeControlStream(AudioManager.STREAM_MUSIC); mediaPlayer = buildMediaPlayer(activity); } }
private synchronized void updatePrefs() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); playBeep = shouldBeep(prefs, activity); vibrate = true; if (playBeep && mediaPlayer == null) { // The volume on STREAM_SYSTEM is not adjustable, and users found it // too loud, // so we now play on the music stream. activity.setVolumeControlStream(AudioManager.STREAM_MUSIC); mediaPlayer = buildMediaPlayer(activity); } }
private synchronized void updatePrefs() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); playBeep = shouldBeep(prefs, activity); vibrate = true; if (playBeep && mediaPlayer == null) { // The volume on STREAM_SYSTEM is not adjustable, and users found it // too loud, // so we now play on the music stream. activity.setVolumeControlStream(AudioManager.STREAM_MUSIC); mediaPlayer = buildMediaPlayer(activity); } }
public synchronized void updatePrefs() { playBeep = shouldBeep(activity); if (playBeep && mediaPlayer == null) { // The volume on STREAM_SYSTEM is not adjustable, and users found it too loud, // so we now play on the music stream. activity.setVolumeControlStream(AudioManager.STREAM_MUSIC); mediaPlayer = buildMediaPlayer(activity); } }
void hideNotification() { if (mTab == null) { return; } MediaNotificationManager.hide(mTab.getId(), R.id.media_playback_notification); Activity activity = getActivityFromTab(mTab); if (activity != null) { activity.setVolumeControlStream(mPreviousVolumeControlStream); } mNotificationInfoBuilder = null; }