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:net.illusor.swipeplayer.activities.SwipeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
    this.setContentView(R.layout.activity_swipe);

    this.menuOptions = (SlidingMenu) this.findViewById(R.id.id_playlist_menu);
    this.viewPager = (ViewPager) this.findViewById(R.id.id_swipe_view_pager);
    this.viewPager.setOnPageChangeListener(new OnSwipeListener());
    this.pagerAdapter = new LocalPagerAdapter(this.getSupportFragmentManager());
    this.durationDisplay = (DurationDisplayView) this.findViewById(R.id.id_audio_durations);

    this.handleIncomingIntent(this.getIntent());
}

From source file:org.catrobat.catroid.ui.BackPackActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle(R.string.backpack_title);/*from  w ww  .  j  ava 2  s.  c om*/
    setContentView(R.layout.activity_script);
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    currentFragmentPosition = FRAGMENT_BACKPACK_SCRIPTS;

    if (savedInstanceState == null) {
        Bundle bundle = this.getIntent().getExtras();

        if (bundle != null) {
            currentFragmentPosition = bundle.getInt(EXTRA_FRAGMENT_POSITION, FRAGMENT_BACKPACK_SCRIPTS);
            backpackItem = bundle.getBoolean(BACKPACK_ITEM);
        }
    }

    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    setCurrentFragment(currentFragmentPosition);
    fragmentTransaction.commit();
    fragmentTransaction.add(R.id.script_fragment_container, currentFragment, currentFragmentTag);

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);
}

From source file:com.metinkale.prayerapp.vakit.AlarmReceiver.java

public static int getStreamType(Context c) {
    String ezanvolume = PreferenceManager.getDefaultSharedPreferences(c).getString("ezanvolume", "noti");
    switch (ezanvolume) {
    case "alarm":
        return AudioManager.STREAM_ALARM;
    case "media":
        return AudioManager.STREAM_MUSIC;
    default://w ww .  j a va 2 s. co m
        return AudioManager.STREAM_RING;

    }
}

From source file:org.digitalcampus.oppia.utils.mediaplayer.VideoPlayerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video_player);
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    videoSurface = (SurfaceView) findViewById(R.id.videoSurface);
    SurfaceHolder videoHolder = videoSurface.getHolder();
    videoHolder.addCallback(this);

    player = new MediaPlayer();
    controller = new VideoControllerView(this);

    Bundle bundle = this.getIntent().getExtras();
    if (bundle != null) {
        mediaFileName = (String) bundle.getSerializable(MEDIA_TAG);
        activity = (Activity) bundle.getSerializable(Activity.TAG);
        course = (Course) bundle.getSerializable(Course.TAG);
    } else {//www  .  j a  v  a2s .c  om
        this.finish();
    }

    try {
        player.setAudioStreamType(AudioManager.STREAM_MUSIC);
        player.setDataSource(this, Uri.parse(FileUtils.getMediaPath(this) + mediaFileName));
        player.setOnPreparedListener(this);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:hku.fyp14017.blencode.ui.BackPackActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle(hku.fyp14017.blencode.R.string.backpack_title);
    setContentView(hku.fyp14017.blencode.R.layout.activity_script);
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    currentFragmentPosition = FRAGMENT_BACKPACK_SCRIPTS;

    if (savedInstanceState == null) {
        Bundle bundle = this.getIntent().getExtras();

        if (bundle != null) {
            currentFragmentPosition = bundle.getInt(EXTRA_FRAGMENT_POSITION, FRAGMENT_BACKPACK_SCRIPTS);
            backpackItem = bundle.getBoolean(BACKPACK_ITEM);
        }//w  ww.  j a va 2 s. co  m
    }

    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    setCurrentFragment(currentFragmentPosition);
    fragmentTransaction.commit();
    fragmentTransaction.add(hku.fyp14017.blencode.R.id.script_fragment_container, currentFragment,
            currentFragmentTag);

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);
}

From source file:fi.mikuz.boarder.gui.internet.Favorites.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle("Favorite Uploads");
    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
    setContentView(R.layout.internet_uploads_list);

    mList = new ArrayList<InternetVersionBoard>();
    mListView = (ListView) findViewById(android.R.id.list);
    mMaxResults = 40;//from   w  ww  .  j ava2 s. com

    mWaitDialog = new TimeoutProgressDialog(Favorites.this, "Waiting for response", TAG, true);

    Bundle extras = getIntent().getExtras();
    @SuppressWarnings("unchecked")
    HashMap<String, String> lastSession = (HashMap<String, String>) extras
            .getSerializable(InternetMenu.LOGIN_KEY);

    try {
        mUserId = lastSession.get(InternetMenu.USER_ID_KEY);
        mSessionToken = lastSession.get(InternetMenu.SESSION_TOKEN_KEY);

        refreshList();
        getListView().setOnScrollListener(this);
    } catch (NullPointerException e) {
        Toast.makeText(Favorites.this, "Please login", Toast.LENGTH_LONG).show();
        Favorites.this.finish();
    }

}

From source file:com.twp.music.LocalMusicActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //Activity??/*from w  w w . j  a v a2  s.  c om*/
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
    setContentView(R.layout.activity_local_music);
    allMusic = (RadioButton) findViewById(R.id.radioAllMusic);
    artistBrowse = (RadioButton) findViewById(R.id.radioArtistBrowse);
    dirBrowse = (RadioButton) findViewById(R.id.radioDirBrowse);
    allMusic.setOnCheckedChangeListener(this);
    artistBrowse.setOnCheckedChangeListener(this);
    dirBrowse.setOnCheckedChangeListener(this);
    findViewById(R.id.imgBack).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });
    checkedPage(LocalType.ALLMUSIC);
    mToken = MusicUtils.bindToService(this, this);
    registerStatusChange();
}

From source file:fi.mikuz.boarder.gui.internet.Login.java

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

    mDbHelper = new LoginDbAdapter(Login.this);
    mDbHelper.open();/* w  ww  .  j  a v a2  s .c  o m*/

    Bundle extras = getIntent().getExtras();
    if (extras.getSerializable(InternetMenu.LOGIN_KEY) != null) {
        mWaitDialog = new TimeoutProgressDialog(Login.this, "Logging out", TAG, true);

        @SuppressWarnings("unchecked")
        HashMap<String, String> lastSession = (HashMap<String, String>) extras
                .getSerializable(InternetMenu.LOGIN_KEY);
        mReturnSession = lastSession;

        mDbHelper.deleteLogin(InternetMenu.USER_ID_KEY);
        mDbHelper.deleteLogin(InternetMenu.SESSION_TOKEN_KEY);
        HashMap<String, String> sendList = new HashMap<String, String>();
        sendList.put(InternetMenu.USER_ID_KEY, lastSession.get(InternetMenu.USER_ID_KEY));
        sendList.put(InternetMenu.SESSION_TOKEN_KEY, lastSession.get(InternetMenu.SESSION_TOKEN_KEY));
        new ConnectionManager(Login.this, InternetMenu.mLogoutURL, sendList);
    } else {
        showLoggedOutView();
    }

}

From source file:hyplink.net.pot.GameActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // load logic
    grid = new Grid();
    // load controller
    controller = new SwipeController(this);
    // load data/*from   w  ww  .  ja  va 2s.  c o m*/
    gamePreferences = new GamePreferences(this);
    // load sound
    audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    soundPool = new SoundPool(20, AudioManager.STREAM_MUSIC, 0);
    // load view
    setOrientation();
    StartAppSDK.init(this, "108710732", "208747074", true);
    StartAppAd.showSplash(this, savedInstanceState);
    setContentView(R.layout.game);
    loadView();
    // load animation
    animation = AnimationUtils.loadAnimation(this, R.anim.cell_animation);
}

From source file:com.reallynourl.nourl.fmpfoldermusicplayer.backend.MediaService.java

private boolean requestAudioFocus() {
    AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    int result = audioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);

    if (result != AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
        mIsPreparedToPlay = false;/*from www  .  j a  va2  s  .  com*/
        Toast.makeText(getApplicationContext(), "Failed to get audio focus. Not starting playback.",
                Toast.LENGTH_LONG).show();
        if (mMediaPlayer != null) {
            mMediaPlayer.stop();
        }
        return false;
    } else {
        mMediaPlayer.setVolume(1.0f, 1.0f);
    }
    return true;
}