getAudioSessionId(), getCurrentPosition(), and pause().
and I try any Listener interface implement.
onCompletion(), onError(), onInfo(), onVideoSizeChanged(),
- when app play clip, onVideoSizeChanged() is called soon.
- when app run clip end, onCompletion() is called.
- If setLoop(true), onCompletion() isn't call. but onInfo() is called by what = 1 and extra = 44.
I used getAudioSessionId(), getCurrentPosition().
Log.d("player", "getAudioSessionId = " + _mediaplayer.getAudioSessionId()); Log.d("player", "getCurrentPosition = " + _mediaplayer.getCurrentPosition());
I designed as if app play clip, app call pause and if app pause, app play clip.
boolean isPause = false; ・・・・ if (isPause == false) { isPause = true; _mediaplayer.pause(); } else { isPause = false; _mediaplayer.start(); }Implements Listeners:
@Override public void onCompletion(MediaPlayer mp) { Log.d("player", "onCompletion"); } @Override public boolean onError(MediaPlayer mp, int what, int extra) { Log.d("player", "onError what = " + what + "extra = " + extra); return false; } @Override public boolean onInfo(MediaPlayer mp, int what, int extra) { Log.d("player", "onInfo what = " + what + "extra = " + extra); return false; } @Override public void onVideoSizeChanged(MediaPlayer mp, int width, int height) { Log.d("player", "onVideoSizeChanged width = " + width + " height = " + height); } @Override public void onPrepared(MediaPlayer mp) { Log.d("player", "onPrepared"); }
Must Register listener before MediaPlayer.start():
_mediaplayer.setOnCompletionListener(this); _mediaplayer.setOnErrorListener(this); _mediaplayer.setOnInfoListener(this); _mediaplayer.setOnPreparedListener(this); _mediaplayer.setOnVideoSizeChangedListener(this);My source code is here.
0 件のコメント:
コメントを投稿