MediaPlayer create and start : MediaPlayer « Media « Android






MediaPlayer create and start

   
//package com.geekadoo.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.media.MediaPlayer;

public class MutableMediaPlayer {
  private static final String PREFS_NAME = "YANIV_PREFS";
  private static final String SILENT_MODE_PROPERTY = "silentMode";

  public static void play(Context context, int resId) {
    SharedPreferences settings = context
        .getSharedPreferences(PREFS_NAME, 0);
    boolean silent = settings.getBoolean(SILENT_MODE_PROPERTY, false);

    if (!silent) {
      MediaPlayer.create(context,  resId).start();
    }
  }

}

   
    
    
  








Related examples in the same category

1.Using MediaPlayer to play MP3 file
2.MediaPlayer and Text to Speech
3.Load mp3 file with MediaPlayer and play
4.Call prepare for MediaPlayer before starting
5.Set URL data source for MediaPlayer
6.Audio MediaPlayer Demo
7.Using MediaPlayer to play Video and Audio
8.extends MediaPlayer
9.Multi PlayMixer
10.Play movie.m4v file
11.Using Service to play media file