use of android.media.MediaPlayer.OnPreparedListener in project AndroidSDK-RecipeBook by gabu.
the class Recipe061 method onResume.
// ホームボタンで閉じて戻ってきた時に
// MediaPlayerを正しい状態にしてあげるため
// onCreateではなくonResumeで準備する
@Override
public void onResume() {
super.onResume();
mMediaPlayer = MediaPlayer.create(this, R.raw.sample);
mMediaPlayer.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
isPrepared = true;
// 準備ができて自動的に再生したいなら、ここでstartメソッドを呼ぶ
// mp.start();
}
});
mSoundPool = new SoundPool(MAX_SOUND_COUNT, AudioManager.STREAM_MUSIC, 0);
mSounds[0] = mSoundPool.load(this, R.raw.sample, 1);
}
use of android.media.MediaPlayer.OnPreparedListener in project howabout-android by recomio.
the class MusicPlayerService method onCreate.
@Override
public void onCreate() {
super.onCreate();
contentManager.start(this);
FlurryAgent.onStartSession(this, FLURRY_API_KEY);
mediaPlayer.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mediaPlayer) {
if (groovesharkStreamUrlGetter != null) {
groovesharkStreamUrlGetter.isStopped(true);
}
isLoaded = false;
playlistAdapter.playNext();
playlistAdapter.notifyDataSetChanged();
}
});
mediaPlayer.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
mediaPlayer.start();
isLoading = false;
isLoaded = true;
playlistAdapter.notifyDataSetChanged();
}
});
}
Aggregations