Commit 377fc2f2 authored by François Beaufort's avatar François Beaufort Committed by Commit Bot

[Picture-in-Picture] Show/hide window.

This CL makes sure that calling video.requestPictureInPicture() shows a
Picture-in-Picture window and that setting disablePictureInPicture to
true or calling document.exitPictureInPicture() hides the
Picture-in-Picture window.

Bug: 806249
Change-Id: Ifa9e6df55c913d6eb68fd0fbb59450d3d516ee1c
Reviewed-on: https://chromium-review.googlesource.com/1006956Reviewed-by: default avatarapacible <apacible@chromium.org>
Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
Cr-Commit-Position: refs/heads/master@{#550572}
parent c5048318
......@@ -2601,6 +2601,11 @@ void HTMLMediaElement::enterPictureInPicture() {
GetWebMediaPlayer()->EnterPictureInPicture();
}
void HTMLMediaElement::exitPictureInPicture() {
if (GetWebMediaPlayer())
GetWebMediaPlayer()->ExitPictureInPicture();
}
double HTMLMediaElement::EffectiveMediaVolume() const {
if (muted_)
return 0;
......
......@@ -212,6 +212,7 @@ class CORE_EXPORT HTMLMediaElement
void setMuted(bool);
virtual bool SupportsPictureInPicture() const { return false; }
void enterPictureInPicture();
void exitPictureInPicture();
void TogglePlayState();
......
......@@ -8,6 +8,7 @@
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/html/media/html_video_element.h"
#include "third_party/blink/renderer/modules/picture_in_picture/picture_in_picture_controller_impl.h"
namespace blink {
......@@ -40,7 +41,9 @@ ScriptPromise DocumentPictureInPicture::exitPictureInPicture(
DOMException::Create(kInvalidStateError, kNoPictureInPictureElement));
}
// TODO(crbug.com/806249): Call element.exitPictureInPicture().
// TODO(crbug.com/806249): Check element is a video element.
// TODO(crbug.com/806249): Returns callback in promise.
ToHTMLVideoElement(picture_in_picture_element)->exitPictureInPicture();
controller.OnClosePictureInPictureWindow();
......
......@@ -69,7 +69,8 @@ ScriptPromise HTMLVideoElementPictureInPicture::requestPictureInPicture(
DOMException::Create(kNotAllowedError, kUserGestureRequired));
}
// TODO(crbug.com/806249): Call element.enterPictureInPicture().
// TODO(crbug.com/806249): Returns callback in promise.
element.enterPictureInPicture();
// TODO(crbug.com/806249): Don't use fake width and height.
PictureInPictureWindow* window = controller.CreatePictureInPictureWindow(
......@@ -114,7 +115,7 @@ void HTMLVideoElementPictureInPicture::SetBooleanAttribute(
PictureInPictureControllerImpl& controller =
PictureInPictureControllerImpl::From(document);
if (controller.PictureInPictureElement(scope) == &element) {
// TODO(crbug.com/806249): Call element.exitPictureInPicture().
element.exitPictureInPicture();
controller.OnClosePictureInPictureWindow();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment