Search in sources :

Example 6 with OnPreparedListener

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);
}
Also used : OnPreparedListener(android.media.MediaPlayer.OnPreparedListener) SoundPool(android.media.SoundPool) MediaPlayer(android.media.MediaPlayer)

Example 7 with OnPreparedListener

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();
        }
    });
}
Also used : OnCompletionListener(android.media.MediaPlayer.OnCompletionListener) OnPreparedListener(android.media.MediaPlayer.OnPreparedListener) MediaPlayer(android.media.MediaPlayer)

Aggregations

MediaPlayer (android.media.MediaPlayer)7 OnPreparedListener (android.media.MediaPlayer.OnPreparedListener)7 MediaController (android.widget.MediaController)3 OnCompletionListener (android.media.MediaPlayer.OnCompletionListener)2 SuppressLint (android.annotation.SuppressLint)1 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)1 SurfaceTexture (android.graphics.SurfaceTexture)1 OnBufferingUpdateListener (android.media.MediaPlayer.OnBufferingUpdateListener)1 OnErrorListener (android.media.MediaPlayer.OnErrorListener)1 OnInfoListener (android.media.MediaPlayer.OnInfoListener)1 OnSeekCompleteListener (android.media.MediaPlayer.OnSeekCompleteListener)1 OnVideoSizeChangedListener (android.media.MediaPlayer.OnVideoSizeChangedListener)1 SoundPool (android.media.SoundPool)1 Uri (android.net.Uri)1 Surface (android.view.Surface)1 ICacheInfo (com.youku.player.apiservice.ICacheInfo)1 VideoCacheInfo (com.youku.player.module.VideoCacheInfo)1 OnPlayHeartListener (com.youku.player.ui.interf.IBaseMediaPlayer.OnPlayHeartListener)1 TaskSendPlayBreak (com.youku.statistics.TaskSendPlayBreak)1 OnADCountListener (com.youku.uplayer.OnADCountListener)1