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

Side by Side 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: Tidy up button name Created 6 years, 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 , m_seeking(false) 347 , m_seeking(false)
348 , m_sentStalledEvent(false) 348 , m_sentStalledEvent(false)
349 , m_sentEndEvent(false) 349 , m_sentEndEvent(false)
350 , m_pausedInternal(false) 350 , m_pausedInternal(false)
351 , m_closedCaptionsVisible(false) 351 , m_closedCaptionsVisible(false)
352 , m_completelyLoaded(false) 352 , m_completelyLoaded(false)
353 , m_havePreparedToPlay(false) 353 , m_havePreparedToPlay(false)
354 , m_tracksAreReady(true) 354 , m_tracksAreReady(true)
355 , m_haveVisibleTextTrack(false) 355 , m_haveVisibleTextTrack(false)
356 , m_processingPreferenceChange(false) 356 , m_processingPreferenceChange(false)
357 , m_remoteRoutesAvailable(false)
358 , m_casting(false)
357 #if ENABLE(OILPAN) 359 #if ENABLE(OILPAN)
358 , m_isFinalizing(false) 360 , m_isFinalizing(false)
359 , m_closeMediaSourceWhenFinalizing(false) 361 , m_closeMediaSourceWhenFinalizing(false)
360 #endif 362 #endif
361 , m_lastTextTrackUpdateTime(-1) 363 , m_lastTextTrackUpdateTime(-1)
362 , m_audioTracks(AudioTrackList::create(*this)) 364 , m_audioTracks(AudioTrackList::create(*this))
363 , m_videoTracks(VideoTrackList::create(*this)) 365 , m_videoTracks(VideoTrackList::create(*this))
364 , m_textTracks(nullptr) 366 , m_textTracks(nullptr)
365 , m_ignoreTrackDisplayUpdate(0) 367 , m_ignoreTrackDisplayUpdate(0)
366 #if ENABLE(WEB_AUDIO) 368 #if ENABLE(WEB_AUDIO)
(...skipping 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after
2271 2273
2272 if (!m_paused) { 2274 if (!m_paused) {
2273 m_paused = true; 2275 m_paused = true;
2274 scheduleTimeupdateEvent(false); 2276 scheduleTimeupdateEvent(false);
2275 scheduleEvent(EventTypeNames::pause); 2277 scheduleEvent(EventTypeNames::pause);
2276 } 2278 }
2277 2279
2278 updatePlayState(); 2280 updatePlayState();
2279 } 2281 }
2280 2282
2283 void HTMLMediaElement::requestRemotePlayback()
2284 {
2285 if (!m_player)
2286 return;
2287 m_player->requestRemotePlayback();
acolwell GONE FROM CHROMIUM 2014/08/05 19:36:34 Use webMediaPlayer() here and below.
acolwell GONE FROM CHROMIUM 2014/08/05 19:36:34 ASSERT(m_remoteRoutesAvailable) here and below so
aberent 2014/08/22 14:08:33 Done.
aberent 2014/08/22 14:08:33 Done.
2288 }
2289
2290 void HTMLMediaElement::requestRemotePlaybackControl()
2291 {
2292 if (!m_player)
2293 return;
2294 m_player->requestRemotePlaybackControl();
2295 }
2296
2281 void HTMLMediaElement::closeMediaSource() 2297 void HTMLMediaElement::closeMediaSource()
2282 { 2298 {
2283 if (!m_mediaSource) 2299 if (!m_mediaSource)
2284 return; 2300 return;
2285 2301
2286 m_mediaSource->close(); 2302 m_mediaSource->close();
2287 m_mediaSource = nullptr; 2303 m_mediaSource = nullptr;
2288 } 2304 }
2289 2305
2290 bool HTMLMediaElement::loop() const 2306 bool HTMLMediaElement::loop() const
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
3160 void HTMLMediaElement::mediaPlayerRequestSeek(double time) 3176 void HTMLMediaElement::mediaPlayerRequestSeek(double time)
3161 { 3177 {
3162 // The player is the source of this seek request. 3178 // The player is the source of this seek request.
3163 if (m_mediaController) { 3179 if (m_mediaController) {
3164 m_mediaController->setCurrentTime(time, IGNORE_EXCEPTION); 3180 m_mediaController->setCurrentTime(time, IGNORE_EXCEPTION);
3165 return; 3181 return;
3166 } 3182 }
3167 setCurrentTime(time, IGNORE_EXCEPTION); 3183 setCurrentTime(time, IGNORE_EXCEPTION);
3168 } 3184 }
3169 3185
3186 void HTMLMediaElement::mediaPlayerRemoteRouteAvailabilityChanged(bool routesAvai lable)
3187 {
3188 m_remoteRoutesAvailable = routesAvailable;
3189 if (hasMediaControls())
3190 mediaControls()->refreshCastButtonVisibility();
3191 }
3192
3193 void HTMLMediaElement::mediaPlayerConnectedToRemoteDevice()
3194 {
3195 m_casting = true;
3196 if (hasMediaControls())
3197 mediaControls()->startedCasting();
3198 }
3199
3200 void HTMLMediaElement::mediaPlayerDisconnectedFromRemoteDevice()
3201 {
3202 m_casting = false;
3203 if (hasMediaControls())
3204 mediaControls()->stoppedCasting();
3205 }
3206
3170 // MediaPlayerPresentation methods 3207 // MediaPlayerPresentation methods
3171 void HTMLMediaElement::mediaPlayerRepaint() 3208 void HTMLMediaElement::mediaPlayerRepaint()
3172 { 3209 {
3173 if (m_webLayer) 3210 if (m_webLayer)
3174 m_webLayer->invalidate(); 3211 m_webLayer->invalidate();
3175 3212
3176 updateDisplayState(); 3213 updateDisplayState();
3177 if (renderer()) 3214 if (renderer())
3178 renderer()->paintInvalidationForWholeRenderer(); 3215 renderer()->paintInvalidationForWholeRenderer();
3179 } 3216 }
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
3635 ensureUserAgentShadowRoot().appendChild(mediaControls); 3672 ensureUserAgentShadowRoot().appendChild(mediaControls);
3636 3673
3637 if (!shouldShowControls() || !inDocument()) 3674 if (!shouldShowControls() || !inDocument())
3638 mediaControls->hide(); 3675 mediaControls->hide();
3639 3676
3640 return true; 3677 return true;
3641 } 3678 }
3642 3679
3643 void HTMLMediaElement::configureMediaControls() 3680 void HTMLMediaElement::configureMediaControls()
3644 { 3681 {
3645 if (!shouldShowControls() || !inDocument()) { 3682 if (!inDocument()) {
acolwell GONE FROM CHROMIUM 2014/08/05 19:36:34 Doesn't removing this end up causing the controls
aberent 2014/08/22 14:08:33 The problem I have is that I need the overlay cast
3646 if (hasMediaControls()) 3683 if (hasMediaControls())
3647 mediaControls()->hide(); 3684 mediaControls()->hide();
3648 return; 3685 return;
3649 } 3686 }
3650 3687
3651 if (!hasMediaControls() && !createMediaControls()) 3688 if (!hasMediaControls() && !createMediaControls())
3652 return; 3689 return;
3653 3690
3654 mediaControls()->reset(); 3691 mediaControls()->reset();
3655 mediaControls()->show(); 3692 if (shouldShowControls())
3693 mediaControls()->show();
3694 else
3695 mediaControls()->hide();
3656 } 3696 }
3657 3697
3658 void HTMLMediaElement::configureTextTrackDisplay(VisibilityChangeAssumption assu mption) 3698 void HTMLMediaElement::configureTextTrackDisplay(VisibilityChangeAssumption assu mption)
3659 { 3699 {
3660 ASSERT(m_textTracks); 3700 ASSERT(m_textTracks);
3661 WTF_LOG(Media, "HTMLMediaElement::configureTextTrackDisplay"); 3701 WTF_LOG(Media, "HTMLMediaElement::configureTextTrackDisplay");
3662 3702
3663 if (m_processingPreferenceChange) 3703 if (m_processingPreferenceChange)
3664 return; 3704 return;
3665 3705
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3705 String kind = textTrack->kind(); 3745 String kind = textTrack->kind();
3706 3746
3707 if (kind == TextTrack::subtitlesKeyword() || kind == TextTrack::captions Keyword()) 3747 if (kind == TextTrack::subtitlesKeyword() || kind == TextTrack::captions Keyword())
3708 textTrack->setHasBeenConfigured(false); 3748 textTrack->setHasBeenConfigured(false);
3709 } 3749 }
3710 configureTextTracks(); 3750 configureTextTracks();
3711 } 3751 }
3712 3752
3713 void* HTMLMediaElement::preDispatchEventHandler(Event* event) 3753 void* HTMLMediaElement::preDispatchEventHandler(Event* event)
3714 { 3754 {
3715 if (event && event->type() == EventTypeNames::webkitfullscreenchange) 3755 if (event && event->type() == EventTypeNames::webkitfullscreenchange) {
acolwell GONE FROM CHROMIUM 2014/08/05 19:36:34 nit: Revert. Change isn't necessary.
aberent 2014/08/22 14:08:33 Done.
3716 configureMediaControls(); 3756 configureMediaControls();
3717 3757 }
3718 return 0; 3758 return 0;
3719 } 3759 }
3720 3760
3721 void HTMLMediaElement::createMediaPlayer() 3761 void HTMLMediaElement::createMediaPlayer()
3722 { 3762 {
3723 AudioSourceProviderClientLockScope scope(*this); 3763 AudioSourceProviderClientLockScope scope(*this);
3724 3764
3725 closeMediaSource(); 3765 closeMediaSource();
3726 3766
3727 m_player = MediaPlayer::create(this); 3767 m_player = MediaPlayer::create(this);
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
3984 4024
3985 #if ENABLE(WEB_AUDIO) 4025 #if ENABLE(WEB_AUDIO)
3986 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 4026 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
3987 { 4027 {
3988 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) 4028 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider())
3989 audioSourceProvider()->setClient(0); 4029 audioSourceProvider()->setClient(0);
3990 } 4030 }
3991 #endif 4031 #endif
3992 4032
3993 } 4033 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698