Skip to content

Commit

Permalink
[Picture-in-Picture] Show last frame when video ends
Browse files Browse the repository at this point in the history
This PR makes sure the last video frame stays visible in the PiP window
when video ends. This is what <video> elements currently do inline.

Bug: 910433
Change-Id: Id6a2065146ca4c76828f3257cd3ee2af7c2eed1b
Reviewed-on: https://chromium-review.googlesource.com/c/1356707
Reviewed-by: Tommy Steimel <[email protected]>
Reviewed-by: Jochen Eisinger <[email protected]>
Reviewed-by: Mounir Lamouri <[email protected]>
Commit-Queue: Mounir Lamouri <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#613343}(cherry picked from commit fdfc67c)
Reviewed-on: https://chromium-review.googlesource.com/c/1361709
Reviewed-by: François Beaufort <[email protected]>
Cr-Commit-Position: refs/branch-heads/3626@{#67}
Cr-Branched-From: d897fb1-refs/heads/master@{#612437}
  • Loading branch information
beaufortfrancois committed Dec 5, 2018
1 parent 22a9b38 commit 84a3578
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
EXPECT_TRUE(in_picture_in_picture);

EXPECT_TRUE(window_controller()->GetWindowForTesting()->IsVisible());
EXPECT_FALSE(
EXPECT_TRUE(
window_controller()->GetWindowForTesting()->GetVideoLayer()->visible());
}

Expand Down
9 changes: 3 additions & 6 deletions chrome/browser/ui/views/overlay/overlay_window_views.cc
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,9 @@ void OverlayWindowViews::UpdateControlsVisibility(bool is_visible) {
#endif

GetControlsScrimLayer()->SetVisible(
(playback_state_ == kNoVideo) ? false : is_visible);
(playback_state_ == kEndOfVideo) ? false : is_visible);
GetControlsParentLayer()->SetVisible(
(playback_state_ == kNoVideo) ? false : is_visible);
(playback_state_ == kEndOfVideo) ? false : is_visible);
}

void OverlayWindowViews::UpdateControlsBounds() {
Expand Down Expand Up @@ -623,19 +623,16 @@ void OverlayWindowViews::SetPlaybackState(PlaybackState playback_state) {
case kPlaying:
play_pause_controls_view_->SetToggled(true);
controls_parent_view_->SetVisible(true);
video_view_->SetVisible(true);
GetControlsParentLayer()->SetVisible(controls_parent_layer_visible);
break;
case kPaused:
play_pause_controls_view_->SetToggled(false);
controls_parent_view_->SetVisible(true);
video_view_->SetVisible(true);
GetControlsParentLayer()->SetVisible(controls_parent_layer_visible);
break;
case kNoVideo:
case kEndOfVideo:
controls_scrim_view_->SetVisible(false);
controls_parent_view_->SetVisible(false);
video_view_->SetVisible(false);
GetControlsParentLayer()->SetVisible(false);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/views/overlay/overlay_window_views.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class OverlayWindowViews : public content::OverlayWindow,

// Current playback state on the video in Picture-in-Picture window. It is
// used to show/hide controls.
PlaybackState playback_state_ = kNoVideo;
PlaybackState playback_state_ = kEndOfVideo;

// The upper and lower bounds of |current_size_|. These are determined by the
// size of the primary display work area when Picture-in-Picture is initiated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ void PictureInPictureWindowControllerImpl::UpdatePlaybackState(
return;

if (reached_end_of_stream) {
media_player_id_.reset();
window_->SetPlaybackState(OverlayWindow::PlaybackState::kNoVideo);
window_->SetPlaybackState(OverlayWindow::PlaybackState::kEndOfVideo);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion content/public/browser/overlay_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class OverlayWindow {
enum PlaybackState {
kPlaying = 0,
kPaused,
kNoVideo,
kEndOfVideo,
};

OverlayWindow() = default;
Expand Down

0 comments on commit 84a3578

Please sign in to comment.