Commit 5a88699d authored by mlamouri's avatar mlamouri Committed by Commit bot

Media Controls: add comments regarding cast/remote related calls from element.

We can't really make the calls use an event in the current situation.
Adding TODO's to explain how it should be done and rename methods for
future usage

BUG=662761
R=zqzhang@chromium.org

Review-Url: https://codereview.chromium.org/2587083002
Cr-Commit-Position: refs/heads/master@{#439514}
parent 2cee23ab
......@@ -548,8 +548,11 @@ void HTMLMediaElement::parseAttribute(const QualifiedName& name,
if (oldValue != value) {
if (m_webMediaPlayer)
m_webMediaPlayer->requestRemotePlaybackDisabled(!value.isNull());
// TODO(mlamouri): there is no direct API to expose if
// disableRemotePLayback attribute has changed. It will require a direct
// access to MediaControls for the moment.
if (mediaControls())
mediaControls()->refreshCastButtonVisibility();
mediaControls()->onDisableRemotePlaybackAttributeChanged();
}
} else {
HTMLElement::parseAttribute(name, oldValue, value);
......@@ -3087,29 +3090,44 @@ void HTMLMediaElement::remoteRouteAvailabilityChanged(
WebRemotePlaybackAvailability availability) {
if (remotePlaybackClient())
remotePlaybackClient()->availabilityChanged(availability);
// TODO(mlamouri): the RemotePlayback object should be used in order to
// register to watch availability but the object is in modules/ and core/ has
// no access to it. It will have to be done when the media controls move to
// modules/.
if (mediaControls())
mediaControls()->refreshCastButtonVisibility();
mediaControls()->onRemotePlaybackAvailabilityChanged();
}
bool HTMLMediaElement::hasRemoteRoutes() const {
// TODO(mlamouri): this is only used for controls related code. It shouldn't
// live in HTMLMediaElement.
return remotePlaybackClient() &&
remotePlaybackClient()->remotePlaybackAvailable();
}
void HTMLMediaElement::connectedToRemoteDevice() {
m_playingRemotely = true;
if (mediaControls())
mediaControls()->startedCasting();
if (remotePlaybackClient())
remotePlaybackClient()->stateChanged(WebRemotePlaybackState::Connecting);
// TODO(mlamouri): the RemotePlayback object should be used in order to listen
// for events but the object is in modules/ and core/ has no access to it. It
// will have to be done when the media controls move to modules/.
if (mediaControls())
mediaControls()->onRemotePlaybackConnecting();
}
void HTMLMediaElement::disconnectedFromRemoteDevice() {
m_playingRemotely = false;
if (mediaControls())
mediaControls()->stoppedCasting();
if (remotePlaybackClient())
remotePlaybackClient()->stateChanged(WebRemotePlaybackState::Disconnected);
// TODO(mlamouri): the RemotePlayback object should be used in order to listen
// for events but the object is in modules/ and core/ has no access to it. It
// will have to be done when the media controls move to modules/.
if (mediaControls())
mediaControls()->onRemotePlaybackDisconnected();
}
void HTMLMediaElement::cancelledRemotePlaybackRequest() {
......
......@@ -65,9 +65,6 @@ class CORE_EXPORT MediaControls final : public HTMLDivElement {
void enteredFullscreen();
void exitedFullscreen();
void startedCasting();
void stoppedCasting();
void refreshCastButtonVisibility();
void showOverlayCastButtonIfNeeded();
// Update cast button visibility, but don't try to update our panel
// button visibility for space.
......@@ -103,6 +100,18 @@ class CORE_EXPORT MediaControls final : public HTMLDivElement {
// be notified on the TextTrack object. See https://crbug.com/669977
void onTrackElementFailedToLoad() { onTextTracksAddedOrRemoved(); }
// TODO(mlamouri): the following methods will be able to become private when
// the controls have moved to modules/ and have access to RemotePlayback.
void onRemotePlaybackAvailabilityChanged() { refreshCastButtonVisibility(); }
void onRemotePlaybackConnecting() { startedCasting(); }
void onRemotePlaybackDisconnected() { stoppedCasting(); }
// TODO(mlamouri): this method is needed in order to notify the controls that
// the attribute have changed.
void onDisableRemotePlaybackAttributeChanged() {
refreshCastButtonVisibility();
}
DECLARE_VIRTUAL_TRACE();
private:
......@@ -163,6 +172,11 @@ class CORE_EXPORT MediaControls final : public HTMLDivElement {
void onError();
void onLoadedMetadata();
// Internal cast related methods.
void startedCasting();
void stoppedCasting();
void refreshCastButtonVisibility();
Member<HTMLMediaElement> m_mediaElement;
// Media control elements.
......
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