Open zaizaixinhtrai opened 6 years ago
MediaPlayer.getDuration() will not change until calling reset
, release
Syslog:
- 11-07 14:00:09.763 27610-27610: reload http://static-devclients.belive.sg/livestreamrecord/140f9046ffe44ad4b610d3d383c79841.mp4
- 11-07 14:00:09.816 27610-30475: [zzy]MediaCodec meet an error
- 11-07 14:00:09.966 27610-27610: updateRecordedBufferedMessageInList
- 11-07 14:00:10.245 27610-27610: time 0 - mFollowHostButtonAnimationDuration 0
- 11-07 14:00:10.254 27610-27610: updateRecordedBufferedMessageInList
- 11-07 14:00:10.393 27610-27610: mMediaPlayer.getDuration()=0
Seems to have made a mistake and MediaPlayer has reloaded. And I am unsing getDuration() in my code:
public void onProgressChanged(SeekBar bar, int progress, boolean fromuser) {
if (mPlayer == null) {
return;
}
if (!fromuser) {
// We're not interested in programmatically generated changes to
// the progress bar's position.
return;
}
long duration = mPlayer.getDuration();
long newposition = (duration * progress) / 1000L;
mPlayer.seekTo((int) newposition);
if (mCurrentTime != null)
mCurrentTime.setText(stringForTime((int) newposition));
}
public void seekTo(int pos) {
if (mMediaPlayer != null) {
Timber.e("mMediaPlayer.getDuration()=" + mMediaPlayer.getDuration());
if (pos == mMediaPlayer.getDuration()) {
// finish open video
} else {
mMediaPlayer.seekTo((long) pos);
}
}
When I seekTo sometime getDuration() return 0 therefore It finish finish open video.
These are what player will do after calling reload
:
Step 1: clean media info about previous video
Step 2: open the new video
Between Step 1 and Step 2, player do not have media info about previous video, so getDuration()
will return 0.
In my code I only call MediaPlayer.seekTo(pos)
not open the new video. But why player call reload
?
I'm sure that reload
will never be called in Player's code.
After calling mMediaPlayer.seekTo(pos) and continuing to play, MediaPlayer.getDuration() sometime return 0. The video already saved in mp4 file. I am using libksylive 2.4.3