Back to project page YouTubePlayerActivity.
The source code is released under:
MIT License
If you think the Android project YouTubePlayerActivity listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.thefinestartist.ytpa.utils; /*from w ww . j a v a 2 s. c o m*/ import android.content.Context; import android.media.AudioManager; /** * Created by TheFinestArtist on 2/12/15. */ public class AudioUtil { private static final Object mSingletonLock = new Object(); private static AudioManager audioManager; private static AudioManager getInstance(Context context) { synchronized (mSingletonLock) { if (audioManager != null) return audioManager; if (context != null) audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); return audioManager; } } public static void adjustMusicVolume(Context context, boolean up, boolean showInterface) { int direction = up ? AudioManager.ADJUST_RAISE : AudioManager.ADJUST_LOWER; int flag = AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE | (showInterface ? AudioManager.FLAG_SHOW_UI : 0); getInstance(context).adjustStreamVolume(AudioManager.STREAM_MUSIC, direction, flag); } public static void playKeyClickSound(Context context, int volume) { if (volume == 0) return; getInstance(context).playSoundEffect(AudioManager.FX_KEY_CLICK, (float) volume / 100.0f); } }