Index: third_party/WebKit/Source/core/html/HTMLVideoElement.cpp |
diff --git a/third_party/WebKit/Source/core/html/HTMLVideoElement.cpp b/third_party/WebKit/Source/core/html/HTMLVideoElement.cpp |
index 3bf2a9d4f7c1d68896882ad758f7047a794e1fac..be12546b3e6742dd911cadcdf77ecb95930bba12 100644 |
--- a/third_party/WebKit/Source/core/html/HTMLVideoElement.cpp |
+++ b/third_party/WebKit/Source/core/html/HTMLVideoElement.cpp |
@@ -39,6 +39,7 @@ |
#include "core/frame/Settings.h" |
#include "core/html/media/MediaCustomControlsFullscreenDetector.h" |
#include "core/html/parser/HTMLParserIdioms.h" |
+#include "core/html/shadow/MediaRemotingInterstitial.h" |
#include "core/imagebitmap/ImageBitmapOptions.h" |
#include "core/layout/LayoutImage.h" |
#include "core/layout/LayoutVideo.h" |
@@ -66,7 +67,9 @@ enum VideoPersistenceControlsType { |
} // anonymous namespace |
inline HTMLVideoElement::HTMLVideoElement(Document& document) |
- : HTMLMediaElement(videoTag, document) { |
+ : HTMLMediaElement(videoTag, document), |
+ media_remoting_status_(kNotStarted), |
+ remoting_interstitial_(nullptr) { |
if (document.GetSettings()) { |
default_poster_url_ = |
AtomicString(document.GetSettings()->GetDefaultVideoPosterURL()); |
@@ -88,6 +91,7 @@ HTMLVideoElement* HTMLVideoElement::Create(Document& document) { |
DEFINE_TRACE(HTMLVideoElement) { |
visitor->Trace(image_loader_); |
visitor->Trace(custom_controls_fullscreen_detector_); |
+ visitor->Trace(remoting_interstitial_); |
HTMLMediaElement::Trace(visitor); |
} |
@@ -179,6 +183,10 @@ void HTMLVideoElement::ParseAttribute( |
// Notify the player when the poster image URL changes. |
if (GetWebMediaPlayer()) |
GetWebMediaPlayer()->SetPoster(PosterImageURL()); |
+ // Media remoting doesn't show the original poster image, instead, it shows |
+ // a grayscaled and blurred copy. |
+ if (remoting_interstitial_) |
+ remoting_interstitial_->OnPosterImageChanged(); |
} else { |
HTMLMediaElement::ParseAttribute(params); |
} |
@@ -480,4 +488,30 @@ ScriptPromise HTMLVideoElement::CreateImageBitmap( |
event_target.ToLocalDOMWindow()->document(), options)); |
} |
+void HTMLVideoElement::MediaRemotingStarted() { |
+ DCHECK_EQ(media_remoting_status_, kNotStarted); |
+ media_remoting_status_ = kStarted; |
+ if (!remoting_interstitial_) { |
+ remoting_interstitial_ = new MediaRemotingInterstitial(*this); |
+ ShadowRoot& shadow_root = EnsureUserAgentShadowRoot(); |
+ shadow_root.InsertBefore(remoting_interstitial_, shadow_root.FirstChild()); |
+ HTMLMediaElement::AssertShadowRootChildren(shadow_root); |
+ } |
+ remoting_interstitial_->Show(); |
+} |
+ |
+void HTMLVideoElement::MediaRemotingStopped() { |
+ if (media_remoting_status_ != kDisabled) |
+ media_remoting_status_ = kNotStarted; |
+ DCHECK(remoting_interstitial_); |
+ remoting_interstitial_->Hide(); |
+} |
+ |
+void HTMLVideoElement::DisableMediaRemoting() { |
+ if (GetWebMediaPlayer()) |
+ GetWebMediaPlayer()->RequestRemotePlaybackDisabled(true); |
+ media_remoting_status_ = kDisabled; |
+ MediaRemotingStopped(); |
+} |
+ |
} // namespace blink |