void MediaControls::defaultEventHandler(Event* event) { HTMLDivElement::defaultEventHandler(event); if (event->type() == EventTypeNames::mouseover) { if (!containsRelatedTarget(event)) { m_isMouseOverControls = true; if (!mediaElement().togglePlayStateWillPlay()) { makeOpaque(); if (shouldHideMediaControls()) startHideMediaControlsTimer(); } } return; } if (event->type() == EventTypeNames::mouseout) { if (!containsRelatedTarget(event)) { m_isMouseOverControls = false; stopHideMediaControlsTimer(); } return; } if (event->type() == EventTypeNames::mousemove) { // When we get a mouse move, show the media controls, and start a timer // that will hide the media controls after a 3 seconds without a mouse move. makeOpaque(); if (shouldHideMediaControls(IgnoreVideoHover)) startHideMediaControlsTimer(); return; } }
void MediaControlRootElement::defaultEventHandler(Event* event) { MediaControls::defaultEventHandler(event); if (event->type() == eventNames().mouseoverEvent) { if (!containsRelatedTarget(event)) { m_isMouseOverControls = true; if (!m_mediaController->canPlay()) { makeOpaque(); if (shouldHideControls()) startHideFullscreenControlsTimer(); } } } else if (event->type() == eventNames().mouseoutEvent) { if (!containsRelatedTarget(event)) { m_isMouseOverControls = false; stopHideFullscreenControlsTimer(); } } else if (event->type() == eventNames().mousemoveEvent) { if (m_isFullscreen) { // When we get a mouse move in fullscreen mode, show the media controls, and start a timer // that will hide the media controls after a 3 seconds without a mouse move. makeOpaque(); if (shouldHideControls()) startHideFullscreenControlsTimer(); } } }
void MediaControls::show() { makeOpaque(); m_panel->setIsWanted(true); m_panel->setIsDisplayed(true); if (m_overlayPlayButton) m_overlayPlayButton->updateDisplayType(); }
void MediaControlRootElementChromium::reset() { Page* page = document()->page(); if (!page) return; updateStatusDisplay(); float duration = m_mediaController->duration(); m_timeline->setDuration(duration); m_timeline->show(); m_durationDisplay->setInnerText(page->theme()->formatMediaControlsTime(duration), ASSERT_NO_EXCEPTION); m_durationDisplay->setCurrentValue(duration); m_timeline->setPosition(m_mediaController->currentTime()); updateTimeDisplay(); m_panelMuteButton->show(); if (m_volumeSlider) { if (!m_mediaController->hasAudio()) m_volumeSlider->hide(); else { m_volumeSlider->show(); m_volumeSlider->setVolume(m_mediaController->volume()); } } if (m_mediaController->supportsFullscreen()) m_fullscreenButton->show(); else m_fullscreenButton->hide(); makeOpaque(); }
void MediaControls::reset() { double duration = mediaElement().duration(); m_durationDisplay->setInnerText(LayoutTheme::theme().formatMediaControlsTime(duration), ASSERT_NO_EXCEPTION); m_durationDisplay->setCurrentValue(duration); updatePlayState(); updateCurrentTimeDisplay(); m_timeline->setDuration(duration); m_timeline->setPosition(mediaElement().currentTime()); if (!mediaElement().hasAudio()) m_volumeSlider->hide(); else m_volumeSlider->show(); updateVolume(); refreshClosedCaptionsButtonVisibility(); if (mediaElement().hasVideo() && fullscreenIsSupported(document())) m_fullScreenButton->show(); else m_fullScreenButton->hide(); refreshCastButtonVisibility(); makeOpaque(); }
void MediaControls::showMediaControls() { makeOpaque(); m_hideTimerBehaviorFlags |= IgnoreControlsHover; if (shouldHideMediaControls(m_hideTimerBehaviorFlags | IgnoreVideoHover)) startHideMediaControlsTimer(); }
void MediaControls::onPause() { updatePlayState(); m_timeline->setPosition(mediaElement().currentTime()); updateCurrentTimeDisplay(); makeOpaque(); stopHideMediaControlsTimer(); }
void MediaControlRootElement::playbackStopped() { m_playButton->updateDisplayType(); m_timeline->setPosition(m_mediaController->currentTime()); updateTimeDisplay(); makeOpaque(); stopHideFullscreenControlsTimer(); }
void MediaControls::defaultEventHandler(Event* event) { HTMLDivElement::defaultEventHandler(event); // Add IgnoreControlsHover to m_hideTimerBehaviorFlags when we see a touch event, // to allow the hide-timer to do the right thing when it fires. // FIXME: Preferably we would only do this when we're actually handling the event // here ourselves. bool wasLastEventTouch = event->isTouchEvent() || event->isGestureEvent() || (event->isMouseEvent() && toMouseEvent(event)->fromTouch()); m_hideTimerBehaviorFlags |= wasLastEventTouch ? IgnoreControlsHover : IgnoreNone; if (event->type() == EventTypeNames::mouseover) { if (!containsRelatedTarget(event)) { m_isMouseOverControls = true; if (!mediaElement().togglePlayStateWillPlay()) { makeOpaque(); if (shouldHideMediaControls()) startHideMediaControlsTimer(); } } return; } if (event->type() == EventTypeNames::mouseout) { if (!containsRelatedTarget(event)) { m_isMouseOverControls = false; stopHideMediaControlsTimer(); } return; } if (event->type() == EventTypeNames::mousemove) { // When we get a mouse move, show the media controls, and start a timer // that will hide the media controls after a 3 seconds without a mouse move. makeOpaque(); refreshCastButtonVisibility(); if (shouldHideMediaControls(IgnoreVideoHover)) startHideMediaControlsTimer(); return; } }
void MediaControls::lockScreen(bool lock) { if (lock) { makeTransparent(); startHideUnlockTimer(); } else { makeOpaque(); if (shouldHideMediaControls()) startHideMediaControlsTimer(); } m_lockEnclosure->setIsWanted(lock); m_mediaElement->setRotateLock(lock); }
void MediaControls::onTimeUpdate() { m_timeline->setPosition(mediaElement().currentTime()); updateCurrentTimeDisplay(); // 'timeupdate' might be called in a paused state. The controls should not // become transparent in that case. if (mediaElement().paused()) { makeOpaque(); return; } if (isVisible() && shouldHideMediaControls()) makeTransparent(); }
void MediaControls::reset() { const bool useNewUi = RuntimeEnabledFeatures::newMediaPlaybackUiEnabled(); BatchedControlUpdate batch(this); m_allowHiddenVolumeControls = useNewUi; m_keepMuteButton = false; const double duration = mediaElement().duration(); m_durationDisplay->setInnerText(LayoutTheme::theme().formatMediaControlsTime(duration), ASSERT_NO_EXCEPTION); m_durationDisplay->setCurrentValue(duration); if (useNewUi) { // Show everything that we might hide. // If we don't have a duration, then mark it to be hidden. For the // old UI case, want / don't want is the same as show / hide since // it is never marked as not fitting. m_durationDisplay->setIsWanted(std::isfinite(duration)); m_currentTimeDisplay->setIsWanted(true); m_timeline->setIsWanted(true); } updatePlayState(); updateCurrentTimeDisplay(); m_timeline->setDuration(duration); m_timeline->setPosition(mediaElement().currentTime()); updateVolume(); refreshClosedCaptionsButtonVisibility(); m_fullScreenButton->setIsWanted(shouldShowFullscreenButton(mediaElement())); refreshCastButtonVisibilityWithoutUpdate(); makeOpaque(); // Set the panel width here, and force a layout, before the controls update. // This would be harmless for the !useNewUi case too, but it causes // compositing/geometry/video-fixed-scrolling.html to fail with two extra // 0 height nodes in the render tree. if (useNewUi) m_panelWidth = m_panel->clientWidth(); }
void MediaControls::reset() { Page* page = document().page(); if (!page) return; m_playButton->updateDisplayType(); updateCurrentTimeDisplay(); double duration = m_mediaController->duration(); if (std::isfinite(duration) || page->theme().hasOwnDisabledStateHandlingFor(MediaSliderPart)) { m_timeline->setDuration(duration); m_timeline->setPosition(m_mediaController->currentTime()); } if (m_mediaController->hasAudio() || page->theme().hasOwnDisabledStateHandlingFor(MediaMuteButtonPart)) m_panelMuteButton->show(); else m_panelMuteButton->hide(); if (m_volumeSlider) { if (!m_mediaController->hasAudio()) m_volumeSlider->hide(); else { m_volumeSlider->show(); setSliderVolume(); } } refreshClosedCaptionsButtonVisibility(); if (m_fullScreenButton) { if (m_mediaController->supportsFullscreen(HTMLMediaElementEnums::VideoFullscreenModeStandard) && m_mediaController->hasVideo()) m_fullScreenButton->show(); else m_fullScreenButton->hide(); } makeOpaque(); }
void MediaControlsApple::reset() { Page* page = document().page(); if (!page) return; updateStatusDisplay(); if (m_mediaController->supportsFullscreen(HTMLMediaElementEnums::VideoFullscreenModeStandard)) m_fullScreenButton->show(); else m_fullScreenButton->hide(); double duration = m_mediaController->duration(); if (std::isfinite(duration) || page->theme().hasOwnDisabledStateHandlingFor(MediaSliderPart)) { m_timeline->setDuration(duration); m_timelineContainer->show(); m_timeline->setPosition(m_mediaController->currentTime()); updateCurrentTimeDisplay(); } else m_timelineContainer->hide(); if (m_mediaController->hasAudio() || page->theme().hasOwnDisabledStateHandlingFor(MediaMuteButtonPart)) m_panelMuteButton->show(); else m_panelMuteButton->hide(); if (m_volumeSlider) setSliderVolume(); if (m_toggleClosedCaptionsButton) { if (m_mediaController->hasClosedCaptions()) m_toggleClosedCaptionsButton->show(); else m_toggleClosedCaptionsButton->hide(); } if (m_playButton) m_playButton->updateDisplayType(); #if ENABLE(FULLSCREEN_API) if (m_fullScreenVolumeSlider) setFullscreenSliderVolume(); if (m_isFullscreen) { if (m_mediaController->isLiveStream()) { m_seekBackButton->hide(); m_seekForwardButton->hide(); m_rewindButton->show(); m_returnToRealTimeButton->show(); } else { m_seekBackButton->show(); m_seekForwardButton->show(); m_rewindButton->hide(); m_returnToRealTimeButton->hide(); } } else #endif if (!m_mediaController->isLiveStream()) { m_returnToRealTimeButton->hide(); m_rewindButton->show(); } else { m_returnToRealTimeButton->show(); m_rewindButton->hide(); } makeOpaque(); }
void MediaControls::show() { makeOpaque(); m_panel->setIsDisplayed(true); m_panel->show(); }
void MediaControls::defaultEventHandler(Event* event) { HTMLDivElement::defaultEventHandler(event); // Add IgnoreControlsHover to m_hideTimerBehaviorFlags when we see a touch // event, to allow the hide-timer to do the right thing when it fires. // FIXME: Preferably we would only do this when we're actually handling the // event here ourselves. bool isTouchEvent = event->isTouchEvent() || event->isGestureEvent() || (event->isMouseEvent() && toMouseEvent(event)->fromTouch()); m_hideTimerBehaviorFlags |= isTouchEvent ? IgnoreControlsHover : IgnoreNone; // Touch events are treated differently to avoid fake mouse events to trigger // random behavior. The expect behaviour for touch is that a tap will show the // controls and they will hide when the timer to hide fires. if (isTouchEvent) { if (event->type() != EventTypeNames::gesturetap) return; if (!containsRelatedTarget(event)) { if (!mediaElement().paused()) { if (!isVisible()) { makeOpaque(); // When the panel switches from invisible to visible, we need to mark // the event handled to avoid buttons below the tap to be activated. event->setDefaultHandled(); } if (shouldHideMediaControls(IgnoreWaitForTimer)) { m_keepShowingUntilTimerFires = true; startHideMediaControlsTimer(); } } } return; } if (event->type() == EventTypeNames::mouseover) { if (!containsRelatedTarget(event)) { m_isMouseOverControls = true; if (!mediaElement().paused()) { makeOpaque(); if (shouldHideMediaControls()) startHideMediaControlsTimer(); } } return; } if (event->type() == EventTypeNames::mouseout) { if (!containsRelatedTarget(event)) { m_isMouseOverControls = false; stopHideMediaControlsTimer(); } return; } if (event->type() == EventTypeNames::mousemove) { // When we get a mouse move, show the media controls, and start a timer // that will hide the media controls after a 3 seconds without a mouse move. makeOpaque(); refreshCastButtonVisibility(); if (shouldHideMediaControls(IgnoreVideoHover)) startHideMediaControlsTimer(); return; } }
void MediaControlRootElement::reset() { Page* page = document()->page(); if (!page) return; updateStatusDisplay(); if (m_mediaController->supportsFullscreen()) m_fullScreenButton->show(); else m_fullScreenButton->hide(); float duration = m_mediaController->duration(); if (isfinite(duration) || page->theme()->hasOwnDisabledStateHandlingFor(MediaSliderPart)) { m_timeline->setDuration(duration); m_timelineContainer->show(); m_timeline->setPosition(m_mediaController->currentTime()); updateTimeDisplay(); } else m_timelineContainer->hide(); if (m_mediaController->hasAudio() || page->theme()->hasOwnDisabledStateHandlingFor(MediaMuteButtonPart)) m_panelMuteButton->show(); else m_panelMuteButton->hide(); if (m_volumeSlider) m_volumeSlider->setVolume(m_mediaController->volume()); if (m_toggleClosedCaptionsButton) { if (m_mediaController->hasClosedCaptions()) m_toggleClosedCaptionsButton->show(); else m_toggleClosedCaptionsButton->hide(); } m_playButton->updateDisplayType(); #if ENABLE(FULLSCREEN_API) if (m_fullScreenVolumeSlider) m_fullScreenVolumeSlider->setVolume(m_mediaController->volume()); if (document()->webkitIsFullScreen() && document()->webkitCurrentFullScreenElement() == toParentMediaElement(this)) { if (m_mediaController->isLiveStream()) { m_seekBackButton->hide(); m_seekForwardButton->hide(); m_rewindButton->show(); m_returnToRealTimeButton->show(); } else { m_seekBackButton->show(); m_seekForwardButton->show(); m_rewindButton->hide(); m_returnToRealTimeButton->hide(); } } else #endif if (!m_mediaController->isLiveStream()) { m_returnToRealTimeButton->hide(); m_rewindButton->show(); } else { m_returnToRealTimeButton->show(); m_rewindButton->hide(); } makeOpaque(); }