Example usage for android.media AudioManager STREAM_MUSIC

List of usage examples for android.media AudioManager STREAM_MUSIC

Introduction

In this page you can find the example usage for android.media AudioManager STREAM_MUSIC.

Prototype

int STREAM_MUSIC

To view the source code for android.media AudioManager STREAM_MUSIC.

Click Source Link

Document

Used to identify the volume of audio streams for music playback

Usage

From source file:Main.java

public static void startPipTone(int duration) {
    new ToneGenerator(AudioManager.STREAM_MUSIC, ToneGenerator.MAX_VOLUME)
            .startTone(ToneGenerator.TONE_CDMA_PIP, duration);
}

From source file:Main.java

public static void useVolumeControl(Activity activity) {
    activity.setVolumeControlStream(AudioManager.STREAM_MUSIC);
}

From source file:Main.java

public static void unmute() {
    audioManager.setStreamMute(AudioManager.STREAM_SYSTEM, false);
    audioManager.setStreamMute(AudioManager.STREAM_MUSIC, false);
}

From source file:Main.java

public static void setCurVolume(Context context, int index) {
    ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_MUSIC,
            index, 0);//from  www .  j  a  v a2  s  .  c o m
}

From source file:Main.java

public static void setVolumeMute(Context mc) {
    AudioManager am = (AudioManager) mc.getSystemService(Context.AUDIO_SERVICE);
    am.setStreamMute(AudioManager.STREAM_MUSIC, true);
}

From source file:Main.java

public static void setVolumeUnmute(Context mc) {
    AudioManager am = (AudioManager) mc.getSystemService(Context.AUDIO_SERVICE);
    am.setStreamMute(AudioManager.STREAM_MUSIC, false);
}

From source file:Main.java

public static int getCurVolume(Context context) {
    return ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE))
            .getStreamVolume(AudioManager.STREAM_MUSIC);
}

From source file:Main.java

public static int getMaxVolume(Context context) {
    return ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE))
            .getStreamMaxVolume(AudioManager.STREAM_MUSIC);
}

From source file:Main.java

public static void stopExtraMusic(Context context) {
    AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    am.requestAudioFocus(null, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
}

From source file:Main.java

public static int getVolumn(Context context) {
    AudioManager audioManger = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    return audioManger.getStreamVolume(AudioManager.STREAM_MUSIC);
}