Esempio n. 1
0
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();
}
Esempio n. 2
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 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;
    }
}
Esempio n. 3
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;
  }
}