Index: Source/core/html/HTMLMediaElement.cpp |
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp |
index a709141682132ddc3829fd251ecc4500baed28bc..cd5589cc9d3477ef7372a2f090133ea96d641261 100644 |
--- a/Source/core/html/HTMLMediaElement.cpp |
+++ b/Source/core/html/HTMLMediaElement.cpp |
@@ -353,6 +353,8 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum |
, m_tracksAreReady(true) |
, m_haveVisibleTextTrack(false) |
, m_processingPreferenceChange(false) |
+ , m_remoteRoutesAvailable(false) |
+ , m_playingRemotely(false) |
#if ENABLE(OILPAN) |
, m_isFinalizing(false) |
, m_closeMediaSourceWhenFinalizing(false) |
@@ -2277,6 +2279,18 @@ void HTMLMediaElement::pause() |
updatePlayState(); |
} |
+void HTMLMediaElement::requestRemotePlayback() |
+{ |
+ ASSERT(m_remoteRoutesAvailable); |
+ webMediaPlayer()->requestRemotePlayback(); |
+} |
+ |
+void HTMLMediaElement::requestRemotePlaybackControl() |
+{ |
+ ASSERT(m_remoteRoutesAvailable); |
+ webMediaPlayer()->requestRemotePlaybackControl(); |
+} |
+ |
void HTMLMediaElement::closeMediaSource() |
{ |
if (!m_mediaSource) |
@@ -3187,6 +3201,27 @@ void HTMLMediaElement::mediaPlayerRequestSeek(double time) |
setCurrentTime(time, ASSERT_NO_EXCEPTION); |
} |
+void HTMLMediaElement::remoteRouteAvailabilityChanged(bool routesAvailable) |
+{ |
+ m_remoteRoutesAvailable = routesAvailable; |
+ if (hasMediaControls()) |
+ mediaControls()->refreshCastButtonVisibility(); |
+} |
+ |
+void HTMLMediaElement::connectedToRemoteDevice() |
+{ |
+ m_playingRemotely = true; |
+ if (hasMediaControls()) |
+ mediaControls()->startedCasting(); |
+} |
+ |
+void HTMLMediaElement::disconnectedFromRemoteDevice() |
+{ |
+ m_playingRemotely = false; |
+ if (hasMediaControls()) |
+ mediaControls()->stoppedCasting(); |
+} |
+ |
// MediaPlayerPresentation methods |
void HTMLMediaElement::mediaPlayerRepaint() |
{ |
@@ -3442,6 +3477,13 @@ void HTMLMediaElement::clearMediaPlayer(int flags) |
m_pendingActionFlags &= ~flags; |
m_loadState = WaitingForSource; |
+ // We can't cast if we don't have a media player. |
+ m_remoteRoutesAvailable = false; |
+ m_playingRemotely = false; |
+ if (hasMediaControls()) { |
+ mediaControls()->refreshCastButtonVisibility(); |
+ } |
+ |
if (m_textTracks) |
configureTextTrackDisplay(AssumeNoVisibleChange); |
} |
@@ -3642,7 +3684,7 @@ bool HTMLMediaElement::createMediaControls() |
void HTMLMediaElement::configureMediaControls() |
{ |
- if (!shouldShowControls() || !inDocument()) { |
+ if (!inDocument()) { |
if (hasMediaControls()) |
mediaControls()->hide(); |
return; |
@@ -3652,7 +3694,10 @@ void HTMLMediaElement::configureMediaControls() |
return; |
mediaControls()->reset(); |
- mediaControls()->show(); |
+ if (shouldShowControls()) |
+ mediaControls()->show(); |
+ else |
+ mediaControls()->hide(); |
} |
void HTMLMediaElement::configureTextTrackDisplay(VisibilityChangeAssumption assumption) |
@@ -3725,6 +3770,10 @@ void HTMLMediaElement::createMediaPlayer() |
m_player = MediaPlayer::create(this); |
+ // We haven't yet found out if any remote routes are available. |
+ m_remoteRoutesAvailable = false; |
+ m_playingRemotely = false; |
+ |
#if ENABLE(WEB_AUDIO) |
if (m_audioSourceNode && audioSourceProvider()) { |
// When creating the player, make sure its AudioSourceProvider knows about the client. |
@@ -3761,7 +3810,7 @@ void HTMLMediaElement::setMediaGroup(const AtomicString& group) |
{ |
// When a media element is created with a mediagroup attribute, and when a media element's mediagroup |
// attribute is set, changed, or removed, the user agent must run the following steps: |
- // 1. Let m [this] be the media element in question. |
+ // 1. Let _R [this] be the media element in question. |
// 2. Let m have no current media controller, if it currently has one. |
setControllerInternal(nullptr); |