Java Code Examples for android.media.AudioManager#adjustVolume()

The following examples show how to use android.media.AudioManager#adjustVolume() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PluginSimplePlayer.java    From Dota2Helper with Apache License 2.0 6 votes vote down vote up
@Override
public void onVolumnUp() {
	if (null != mActivity) {
		AudioManager audioMa = (AudioManager) mActivity
				.getSystemService(Context.AUDIO_SERVICE);
		if (null != mMediaPlayerDelegate
				&& mMediaPlayerDelegate.isFullScreen) {
			audioMa.adjustVolume(AudioManager.ADJUST_SAME,
					AudioManager.FLAG_PLAY_SOUND);
		} else {
			audioMa.adjustStreamVolume(AudioManager.STREAM_MUSIC,
					AudioManager.ADJUST_SAME,
					AudioManager.FX_FOCUS_NAVIGATION_UP);
		}
	}
}
 
Example 2
Source File: PluginSimplePlayer.java    From Dota2Helper with Apache License 2.0 6 votes vote down vote up
@Override
public void onVolumnDown() {
	if (null != mActivity) {
		AudioManager audioMa = (AudioManager) mActivity
				.getSystemService(mActivity.AUDIO_SERVICE);
		if (null != mMediaPlayerDelegate
				&& mMediaPlayerDelegate.isFullScreen) {
			audioMa.adjustVolume(AudioManager.ADJUST_SAME,
					AudioManager.FLAG_PLAY_SOUND);
		} else {
			audioMa.adjustStreamVolume(AudioManager.STREAM_MUSIC,
					AudioManager.ADJUST_SAME,
					AudioManager.FX_FOCUS_NAVIGATION_UP);
		}
	}
}
 
Example 3
Source File: YoukuPluginPlayer.java    From Dota2Helper with Apache License 2.0 6 votes vote down vote up
@Override
public void onVolumnUp() {
    if (null != mActivity) {
        AudioManager audioMa = (AudioManager) mActivity
                .getSystemService(Context.AUDIO_SERVICE);
        if (null != mMediaPlayerDelegate
                && mMediaPlayerDelegate.isFullScreen) {
            audioMa.adjustVolume(AudioManager.ADJUST_SAME,
                    AudioManager.FLAG_PLAY_SOUND);
        } else {
            audioMa.adjustStreamVolume(AudioManager.STREAM_MUSIC,
                    AudioManager.ADJUST_SAME,
                    AudioManager.FX_FOCUS_NAVIGATION_UP);
        }
    }
}
 
Example 4
Source File: YoukuPluginPlayer.java    From Dota2Helper with Apache License 2.0 6 votes vote down vote up
@Override
public void onVolumnDown() {
    if (null != mActivity) {
        AudioManager audioMa = (AudioManager) mActivity
                .getSystemService(mActivity.AUDIO_SERVICE);
        if (null != mMediaPlayerDelegate
                && mMediaPlayerDelegate.isFullScreen) {
            audioMa.adjustVolume(AudioManager.ADJUST_SAME,
                    AudioManager.FLAG_PLAY_SOUND);
        } else {
            audioMa.adjustStreamVolume(AudioManager.STREAM_MUSIC,
                    AudioManager.ADJUST_SAME,
                    AudioManager.FX_FOCUS_NAVIGATION_UP);
        }
    }
}
 
Example 5
Source File: PluginSimplePlayer.java    From SimplifyReader with Apache License 2.0 6 votes vote down vote up
@Override
public void onVolumnUp() {
	if (null != mActivity) {
		AudioManager audioMa = (AudioManager) mActivity
				.getSystemService(Context.AUDIO_SERVICE);
		if (null != mMediaPlayerDelegate
				&& mMediaPlayerDelegate.isFullScreen) {
			audioMa.adjustVolume(AudioManager.ADJUST_SAME,
					AudioManager.FLAG_PLAY_SOUND);
		} else {
			audioMa.adjustStreamVolume(AudioManager.STREAM_MUSIC,
					AudioManager.ADJUST_SAME,
					AudioManager.FX_FOCUS_NAVIGATION_UP);
		}
	}
}
 
Example 6
Source File: PluginSimplePlayer.java    From SimplifyReader with Apache License 2.0 6 votes vote down vote up
@Override
public void onVolumnDown() {
	if (null != mActivity) {
		AudioManager audioMa = (AudioManager) mActivity
				.getSystemService(mActivity.AUDIO_SERVICE);
		if (null != mMediaPlayerDelegate
				&& mMediaPlayerDelegate.isFullScreen) {
			audioMa.adjustVolume(AudioManager.ADJUST_SAME,
					AudioManager.FLAG_PLAY_SOUND);
		} else {
			audioMa.adjustStreamVolume(AudioManager.STREAM_MUSIC,
					AudioManager.ADJUST_SAME,
					AudioManager.FX_FOCUS_NAVIGATION_UP);
		}
	}
}
 
Example 7
Source File: AudioManagerUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 控制手机音量, 调大或者调小一个单位
 * <pre>
 *     AudioManager.ADJUST_LOWER 可调小一个单位
 *     AudioManager.ADJUST_RAISE 可调大一个单位
 * </pre>
 * @param direction 音量方向 ( 调大、调小 )
 * @return {@code true} success, {@code false} fail
 */
public static boolean adjustVolume(final int direction) {
    AudioManager audioManager = AppUtils.getAudioManager();
    if (audioManager != null) {
        try {
            audioManager.adjustVolume(direction, 0);
            return true;
        } catch (Exception e) {
            LogPrintUtils.eTag(TAG, e, "adjustVolume");
        }
    }
    return false;
}
 
Example 8
Source File: VolumeTile.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
@Override
public void handleClick() {
    collapsePanels();
    AudioManager am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
    am.adjustVolume(AudioManager.ADJUST_SAME, AudioManager.FLAG_SHOW_UI);
    super.handleClick();
}
 
Example 9
Source File: DownloadService.java    From Popeens-DSub with GNU General Public License v3.0 4 votes vote down vote up
public void updateRemoteVolume(boolean up) {
	AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
	audioManager.adjustVolume(up ? AudioManager.ADJUST_RAISE : AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI);
}