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

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: Respond to comments 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 90b986d4ac9c2f6e6d3230221b9c0f04188c2f3f..2354e2f8d6a338f964cce833d3d120ea0e434aad 100644
--- a/Source/core/html/HTMLMediaElement.cpp
+++ b/Source/core/html/HTMLMediaElement.cpp
@@ -352,6 +352,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)
@@ -2264,6 +2266,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)
@@ -3174,6 +3188,27 @@ void HTMLMediaElement::mediaPlayerRequestSeek(double time)
setCurrentTime(time, IGNORE_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()
{
@@ -3429,6 +3464,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);
}
@@ -3629,7 +3671,7 @@ bool HTMLMediaElement::createMediaControls()
void HTMLMediaElement::configureMediaControls()
{
- if (!shouldShowControls() || !inDocument()) {
+ if (!inDocument()) {
if (hasMediaControls())
mediaControls()->hide();
return;
@@ -3639,7 +3681,10 @@ void HTMLMediaElement::configureMediaControls()
return;
mediaControls()->reset();
- mediaControls()->show();
+ if (shouldShowControls())
+ mediaControls()->show();
+ else
+ mediaControls()->hide();
}
void HTMLMediaElement::configureTextTrackDisplay(VisibilityChangeAssumption assumption)
@@ -3712,6 +3757,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.
@@ -3748,7 +3797,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