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;
    }
}
Exemple #2
0
void MediaControls::onPlay() {
  updatePlayState();
  m_timeline->setPosition(mediaElement().currentTime());
  updateCurrentTimeDisplay();

  startHideMediaControlsTimer();
}
Exemple #3
0
void MediaControls::showMediaControls()
{
    makeOpaque();

    m_hideTimerBehaviorFlags |= IgnoreControlsHover;
    if (shouldHideMediaControls(m_hideTimerBehaviorFlags | IgnoreVideoHover))
        startHideMediaControlsTimer();
}
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::playbackStarted()
{
    m_currentTimeDisplay->show();
    m_durationDisplay->hide();

    updatePlayState();
    m_timeline->setPosition(mediaElement().currentTime());
    updateCurrentTimeDisplay();

    startHideMediaControlsTimer();
}
Exemple #6
0
void MediaControls::playbackStarted() {
  BatchedControlUpdate batch(this);

  if (!RuntimeEnabledFeatures::newMediaPlaybackUiEnabled()) {
    m_currentTimeDisplay->setIsWanted(true);
    m_durationDisplay->setIsWanted(false);
  }

  updatePlayState();
  m_timeline->setPosition(mediaElement().currentTime());
  updateCurrentTimeDisplay();

  startHideMediaControlsTimer();
}
Exemple #7
0
void MediaControls::lockScreen(bool lock)
{
    if (lock) {
        makeTransparent();
        startHideUnlockTimer();
    } else {
        makeOpaque();
        if (shouldHideMediaControls())
            startHideMediaControlsTimer();
    }

    m_lockEnclosure->setIsWanted(lock);
    m_mediaElement->setRotateLock(lock);
}
Exemple #8
0
void MediaControls::exitedFullscreen()
{
    m_fullScreenButton->setIsFullscreen(false);
    stopHideMediaControlsTimer();
    startHideMediaControlsTimer();

    // stop enhanced video player
    if (m_enhancedUiEnabled) {
        m_lockButton->setIsWanted(false);
        m_zoomButton->setIsWanted(false);
        m_overlayBrightnessSlider->setIsWanted(false);
        m_overlayVolumeSlider->setIsWanted(false);
        m_lockEnclosure->setIsWanted(false);
    }
}
Exemple #9
0
void MediaControls::enteredFullscreen()
{
    m_fullScreenButton->setIsFullscreen(true);
    stopHideMediaControlsTimer();
    startHideMediaControlsTimer();

    // start enhanced video player
    if (m_enhancedUiEnabled) {
        m_lockButton->setIsWanted(true);

        m_zoomButton->setIsWanted(true);
        m_mediaElement->setFitVertical(false);

        m_overlayBrightnessSlider->setIsWanted(true);
        m_overlayVolumeSlider->setIsWanted(true);
    }
}
void MediaControls::resetHideMediaControlsTimer()
{
    stopHideMediaControlsTimer();
    if (!mediaElement().paused())
        startHideMediaControlsTimer();
}
void MediaControls::exitedFullscreen()
{
    m_fullScreenButton->setIsFullscreen(false);
    stopHideMediaControlsTimer();
    startHideMediaControlsTimer();
}
void MediaControls::enteredFullscreen()
{
    m_fullScreenButton->setIsFullscreen(true);
    stopHideMediaControlsTimer();
    startHideMediaControlsTimer();
}
Exemple #13
0
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;
  }
}