ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

Set bookmark ExoPlayer 2.7.0

Open Gian84 opened this issue 8 years ago • 3 comments

Issue description

How should I use bookmark on ExoPlayer 2.7.0? I try to force seek(int positionMs) method but without success. The video starts always from 0. I would like to start a content from a specific position at the first time (not only if the app goes in background and returns in foreground).

(I have noticed that in ExoPlayerImplInternal class in the resetInternal() method resetPosition is true and so pendingInitialSeekPosition is null). Maybe should I wait for a callback before invoke player.seek(positionMs)?

Reproduction steps

In ExoPlayer 2.7.0 demo app force the seek. PlayerActivity - end of initializePlayer() method:

boolean haveResumePosition = resumeWindow != C.INDEX_UNSET;
if (haveResumePosition) {
  player.seekTo(resumeWindow, resumePosition);
}
player.seekTo(5000); // <---- force bookmark
player.prepare(mediaSource, !haveResumePosition, false);
inErrorState = false;
updateButtonVisibilities();

Link to test content

Any link of ExoPlayer demo app

Version of ExoPlayer being used

2.7.0

Device(s) and version(s) of Android being used

Nexus 5X - Android 8.0.0

A full bug report captured from the device

no log

Gian84 avatar Mar 07 '18 11:03 Gian84

@Gian84 just my 2 cent: you have "!haveResumePosition" in your prepare call, which may be false and ExoPlayer will ignore the bookmark you set. Maybe force this to "true" and try again?

eneim avatar Mar 08 '18 01:03 eneim

@eneim answer is correct. The second parameter of player.prepare is resetPosition. So if this is true, all previously set positions will be ignored and the player starts at the default position. That means if you seek before calling prepare, you need to pass false to resetPosition to prevent the reset.

tonihei avatar Mar 08 '18 09:03 tonihei

Exactly!!! :'( I'm a little embarrassed :D Thanks so much @eneim and @tonihei !!!

Gian84 avatar Mar 08 '18 10:03 Gian84