Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(518)

Unified Diff: Source/core/html/HTMLMediaElement.cpp

Issue 291163004: Implement media cast buttons (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase to fix merge problem with TestExpectations Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);

Powered by Google App Engine
This is Rietveld 408576698