List of usage examples for android.media MediaPlayer create
public static MediaPlayer create(Context context, int resid)
From source file:Main.java
public static void runAlarm(Context context, int resourceId) { MediaPlayer mediaPlayer = MediaPlayer.create(context, resourceId); mediaPlayer.setVolume(1.0f, 1.0f);/* w w w . j a va2s. com*/ mediaPlayer.start(); }
From source file:Main.java
public static int m6967a(Context context, String str) { MediaPlayer create = MediaPlayer.create(context, Uri.parse(str)); if (create == null) { return 0; }/*w ww.j a v a 2s. co m*/ int duration = create.getDuration() / 1000; create.reset(); create.release(); return duration; }
From source file:Main.java
public static void playSound(Context context, int soundID) { mMediaPlayer = MediaPlayer.create(context, soundID); mMediaPlayer.setVolume(0.5f, 0.5f);/*from ww w . j ava 2s .co m*/ mMediaPlayer.start(); }
From source file:Main.java
public static void playSoundfile(Context context, int R_raw_fileid) { MediaPlayer mp = MediaPlayer.create(context, R_raw_fileid); mp.setOnCompletionListener(new OnCompletionListener() { @Override//from www. j a v a 2 s .c o m public void onCompletion(MediaPlayer mp) { mp.release(); } }); mp.start(); }
From source file:Main.java
public static void playMusic(int resId) { if (musicSt == false) return;//from w w w .j av a2 s .com music = MediaPlayer.create(context, resId); music.setLooping(true); startMusic(); }
From source file:Main.java
public static void playAudio(Context context, int resId) { if (context == null) throw new NullPointerException("context cannot be null"); mediaPlayer = MediaPlayer.create(context, resId); mediaPlayer.start();/*w w w.j a v a 2s.c om*/ mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { mp.release(); } }); }
From source file:Main.java
public static boolean play(Context context, String name) { Integer id = resources.get(name); if (id == null) return false; MediaPlayer mp = MediaPlayer.create(context, id); if (mp == null) return false; mp.start();/*from w w w . j ava2s.c o m*/ return true; }
From source file:MainActivity.java
public void buttonPlay(View view) { if (mMediaPlayer == null) { mMediaPlayer = MediaPlayer.create(this, R.raw.sound_1); mMediaPlayer.setLooping(true);/*from www .j av a 2 s. c om*/ mMediaPlayer.start(); } else { mMediaPlayer.start(); } }
From source file:projects.oss2015.cs.fundookid.Shoes.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_shoes); mpCheer = MediaPlayer.create(this, R.raw.cheering); mpAww = MediaPlayer.create(this, R.raw.aww); mpRedBoots = MediaPlayer.create(this, R.raw.redboots); mpRedBoots.start();/* www. ja v a 2 s . co m*/ }
From source file:inujini_.hatate.service.PierceReceiver.java
@Override protected void asyncOnReceive(Context context, Intent intent) { Util.dbUpdate(context);/*from ww w. j ava 2 s .co m*/ _statistics = StatisticsDao.getStatistics(context); // if (context.isScream()) { val mp = MediaPlayer.create(context, Love.getVoice(_statistics.getLove())); mp.seekTo(0); mp.start(); mp.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer x) { x.release(); } }); } // val notifyManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); val killIntent = PendingIntent.getService(context, REQ_KILL, new Intent(context, Kill.class), PendingIntent.FLAG_UPDATE_CURRENT); val notify = new NotificationCompat.Builder(context).setSmallIcon(R.drawable.ic_launcher) .setTicker("!!!").setWhen(System.currentTimeMillis()) .setContentTitle("Hatate Houtyou Alarm") .setContentText("!!!").setContentIntent(killIntent) .setDeleteIntent(killIntent); // LED if (context.isLight()) { notify.setLights((int) context.getLightColor(), 3000, 3000); } // ? if (context.isVibration()) { notify.setVibrate(context.getVibrationPattern()); } notifyManager.notify(NOTIFY_HATATE_HOUTYOU, notify.build()); // if (context.isSnooze()) { Util.setSnooze(context); } onAfterPierced(context, intent); }