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

  if (isVisible() && shouldHideMediaControls())
    makeTransparent();
}
Beispiel #3
0
void MediaControls::showMediaControls()
{
    makeOpaque();

    m_hideTimerBehaviorFlags |= IgnoreControlsHover;
    if (shouldHideMediaControls(m_hideTimerBehaviorFlags | IgnoreVideoHover))
        startHideMediaControlsTimer();
}
void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*)
{
    if (mediaElement().togglePlayStateWillPlay())
        return;

    if (!shouldHideMediaControls(IgnoreFocus | IgnoreVideoHover))
        return;

    makeTransparent();
}
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::hideMediaControlsTimerFired(Timer<MediaControls>*)
{
    unsigned behaviorFlags = m_hideTimerBehaviorFlags | IgnoreFocus | IgnoreVideoHover;
    m_hideTimerBehaviorFlags = IgnoreNone;

    if (mediaElement().togglePlayStateWillPlay())
        return;

    if (!shouldHideMediaControls(behaviorFlags))
        return;

    makeTransparent();
}
Beispiel #7
0
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::hideMediaControlsTimerFired(Timer<MediaControls>*)
{
    unsigned behaviorFlags = m_hideTimerBehaviorFlags | IgnoreFocus | IgnoreVideoHover;
    m_hideTimerBehaviorFlags = IgnoreNone;

    if (mediaElement().paused())
        return;

    if (!shouldHideMediaControls(behaviorFlags))
        return;

    makeTransparent();
    m_overlayCastButton->setIsWanted(false);
}
Beispiel #9
0
void MediaControls::lockScreen(bool lock)
{
    if (lock) {
        makeTransparent();
        startHideUnlockTimer();
    } else {
        makeOpaque();
        if (shouldHideMediaControls())
            startHideMediaControlsTimer();
    }

    m_lockEnclosure->setIsWanted(lock);
    m_mediaElement->setRotateLock(lock);
}
void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*)
{
    if (mediaElement().togglePlayStateWillPlay())
        return;

    unsigned behaviorFlags = IgnoreFocus | IgnoreVideoHover;
    // FIXME: improve this check, see http://www.crbug.com/401177.
    if (!deviceSupportsMouse(document())) {
        behaviorFlags |= IgnoreControlsHover;
    }
    if (!shouldHideMediaControls(behaviorFlags))
        return;

    makeTransparent();
}
Beispiel #11
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;
  }
}