return;
}
- // If seek_cb isn't set, then this call is due to the StartPlayingFrom() call
- // in the renderer. In which case, ignore a seek to 0.0.
- if (!seek_cb) {
- // Ignore seek to 0 during initialization.
- if (GetPlayerState() < PLAYER_STATE_READY && time.InSecondsF() == 00) {
- LOG_ID(INFO, player_id_)
- << __func__ << " Ignore seek to invalid time during initialization.";
- return;
- }
+ const bool is_initializing = GetPlayerState() < PLAYER_STATE_READY;
+ const bool is_suspend_seek = IsPlayerSuspended() && playback_time_ != time;
+ const bool is_start_playing_from_zero = !seek_cb && time.is_zero();
+
+ if (is_initializing && is_start_playing_from_zero) {
+ LOG_ID(INFO, player_id_) << "Ignore initial seek";
+ return;
}
+
seek_cb_ = std::move(seek_cb);
- bool is_suspend_seek = IsPlayerSuspended() && playback_time_ != time;
- if (is_seeking_ || is_suspend_seek || waiting_for_drm_init_complete_ ||
- is_preparing_ || is_preloading_) {
+
+ // in the case when the player is currently unable to seek, stash the seek
+ // it will be executed in |MediaPlayerBridgeCapi::ExecuteDelayedPlayerState|
+ const bool should_stash_seek =
+ is_seeking_ || is_suspend_seek || waiting_for_drm_init_complete_ ||
+ is_preparing_ || is_preloading_ || is_initializing;
+
+ if (should_stash_seek) {
LOG_ID(INFO, player_id_)
<< "(" << static_cast<void*>(this) << ") "
<< " stashing pending seek - " << time.InSecondsF() << "s";