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:com.darly.im.ui.BaseFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mAudioManager = AudioManagerTools.getInstance().getAudioManager();
    mMusicMaxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
}

From source file:org.dharmaseed.android.TalkPlayerFragment.java

public TalkPlayerFragment() {
    mediaPlayer = new MediaPlayer();
    mediaPlayer.setOnPreparedListener(this);
    mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    mediaPrepared = false;/*from w  w  w.j av  a2s.c o  m*/
    userSeekBarPosition = 0;
}

From source file:ca.rmen.android.networkmonitor.app.speedtest.SpeedTestAboutActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_speed_test_about);
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction().add(R.id.container, new SpeedTestAboutFragment())
                .commit();//from   w  w  w  .  j a v a2s  . c om
    }
}

From source file:ca.rmen.android.palidamuerte.app.category.list.CategoriesActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mHandler = new Handler();
    setContentView(R.layout.activity_categories);
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    getActionBar().setCustomView(R.layout.actionbar_title);
    getActionBar().setDisplayShowTitleEnabled(false);
    getActionBar().setDisplayShowHomeEnabled(false);
    getActionBar().setDisplayShowCustomEnabled(true);
}

From source file:com.darly.im.ui.BaseFragment.java

/**
 * ?,??/*from  www.  j  av  a2  s  . c o m*/
 * @param keyCode
 * @param event
 */
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if ((event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP) && mAudioManager != null) {
        int streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
        if (streamVolume >= mMusicMaxVolume) {
            LogUtil.d(LogUtil.getLogUtilsTag(BaseFragment.class), "has set the max volume");
            return true;
        }
        int mean = mMusicMaxVolume / 7;
        if (mean == 0) {
            mean = 1;
        }
        mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, streamVolume + mean,
                AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI);
        return true;
    }
    if ((event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN) && mAudioManager != null) {
        int streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
        int mean = mMusicMaxVolume / 7;
        if (mean == 0) {
            mean = 1;
        }
        mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, streamVolume - mean,
                AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI);
        return true;
    }

    return super.onKeyDown(keyCode, event);
}

From source file:MainActivity.java

@SuppressWarnings("deprecation")
private void createSoundPooolOld() {
    mSoundPool = new SoundPool(2, AudioManager.STREAM_MUSIC, 0);
}

From source file:com.gao.im.ui.BaseFragment.java

/**
 * ?,??/*from  w  ww  . j av  a  2  s .  co m*/
 * @param keyCode
 * @param event
 */
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if ((event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP) && mAudioManager != null) {
        int streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
        if (streamVolume >= mMusicMaxVolume) {
            LogUtil.d(LogUtil.getLogUtilsTag(BaseFragment.class), "has set the max volume");
            return true;
        }
        int mean = mMusicMaxVolume / 7;
        if (mean == 0) {
            mean = 1;
        }
        mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, streamVolume + mean,
                AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI);
        return true;
    }
    if ((event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN) && mAudioManager != null) {
        int streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
        int mean = mMusicMaxVolume / 7;
        if (mean == 0) {
            mean = 1;
        }
        mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, streamVolume - mean,
                AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI);
        return true;
    }

    return super.onKeyDown(keyCode, event);
}

From source file:com.qweex.callisto.Live.java

/** Initiates the live player. Can be called across activities. */
static public void LIVE_Init() {
    String TAG = StaticBlob.TAG();
    Log.d(TAG, "Initiating the live player.");
    live_player = new MediaPlayer();
    Log.d(TAG, "Initiating the live player.");
    live_player.setAudioStreamType(AudioManager.STREAM_MUSIC);
    Log.d(TAG, "Initiating the live player.");
    live_player.setOnErrorListener(new MediaPlayer.OnErrorListener() {
        public boolean onError(MediaPlayer mp, int what, int extra) {
            if (LIVE_PreparedListener.pd != null)
                LIVE_PreparedListener.pd.hide();
            String whatWhat = "";
            switch (what) {
            case MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK:
                whatWhat = "MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK";
                break;
            case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
                whatWhat = "MEDIA_ERROR_SERVER_DIED";
                break;
            case MediaPlayer.MEDIA_ERROR_UNKNOWN:
                whatWhat = "MEDIA_ERROR_UNKNOWN";
                break;
            default:
                whatWhat = "???";
                return true;
            }/*from  ww w. j av  a2s.  c  om*/
            try {
                if (StaticBlob.errorDialog != null)
                    StaticBlob.errorDialog.show();
            } catch (Exception e) {
            }

            try {
                SendErrorReport(whatWhat);
            } catch (Exception e) {
            }
            return true;
        }
    });
    Log.d(TAG, "Initiating the live player.");
}

From source file:com.doctoror.fuckoffmusicplayer.presentation.base.BaseActivity.java

@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
    AndroidInjection.inject(this);

    themeUsed = settings.getTheme();//  w  w w .j a  v  a 2 s  .  com

    fragmentTransactionsAllowed = true;
    finishingAfterTransition = false;
}

From source file:ca.uqac.florentinth.speakerauthentication.CreateActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_create);

    this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    initGUI();/*from  w  w  w .  j  a  va  2  s .  c  o  m*/
}