OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights |
3 * reserved. | 3 * reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1481 } else { | 1481 } else { |
1482 BLINK_MEDIA_LOG << "mediaLoadingFailed(" << (void*)this | 1482 BLINK_MEDIA_LOG << "mediaLoadingFailed(" << (void*)this |
1483 << ") - no more <source> elements, waiting"; | 1483 << ") - no more <source> elements, waiting"; |
1484 waitForSourceChange(); | 1484 waitForSourceChange(); |
1485 } | 1485 } |
1486 | 1486 |
1487 return; | 1487 return; |
1488 } | 1488 } |
1489 | 1489 |
1490 if (error == WebMediaPlayer::NetworkStateNetworkError && | 1490 if (error == WebMediaPlayer::NetworkStateNetworkError && |
1491 m_readyState >= kHaveMetadata) | 1491 m_readyState >= kHaveMetadata) { |
1492 mediaEngineError(MediaError::create(MediaError::kMediaErrNetwork)); | 1492 mediaEngineError(MediaError::create(MediaError::kMediaErrNetwork)); |
1493 else if (error == WebMediaPlayer::NetworkStateDecodeError) | 1493 } else if (error == WebMediaPlayer::NetworkStateDecodeError) { |
1494 mediaEngineError(MediaError::create(MediaError::kMediaErrDecode)); | 1494 mediaEngineError(MediaError::create(MediaError::kMediaErrDecode)); |
1495 else if ((error == WebMediaPlayer::NetworkStateFormatError || | 1495 } else if ((error == WebMediaPlayer::NetworkStateFormatError || |
1496 error == WebMediaPlayer::NetworkStateNetworkError) && | 1496 error == WebMediaPlayer::NetworkStateNetworkError) && |
1497 m_loadState == LoadingFromSrcAttr) | 1497 m_loadState == LoadingFromSrcAttr) { |
1498 noneSupported(); | 1498 noneSupported(); |
1499 } | |
1499 | 1500 |
1500 updateDisplayState(); | 1501 updateDisplayState(); |
1501 if (mediaControls()) | |
Zhiqiang Zhang (Slow)
2016/12/19 17:41:39
Question: I saw the error event is only fired in t
mlamouri (slow - plz ping)
2016/12/19 17:57:26
`mediaEngineError()` and `noneSupported()` both fi
| |
1502 mediaControls()->reset(); | |
1503 } | 1502 } |
1504 | 1503 |
1505 void HTMLMediaElement::setNetworkState(WebMediaPlayer::NetworkState state) { | 1504 void HTMLMediaElement::setNetworkState(WebMediaPlayer::NetworkState state) { |
1506 BLINK_MEDIA_LOG << "setNetworkState(" << (void*)this << ", " | 1505 BLINK_MEDIA_LOG << "setNetworkState(" << (void*)this << ", " |
1507 << static_cast<int>(state) << ") - current state is " | 1506 << static_cast<int>(state) << ") - current state is " |
1508 << static_cast<int>(m_networkState); | 1507 << static_cast<int>(m_networkState); |
1509 | 1508 |
1510 if (state == WebMediaPlayer::NetworkStateEmpty) { | 1509 if (state == WebMediaPlayer::NetworkStateEmpty) { |
1511 // Just update the cached state and leave, we can't do anything. | 1510 // Just update the cached state and leave, we can't do anything. |
1512 setNetworkState(kNetworkEmpty); | 1511 setNetworkState(kNetworkEmpty); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1651 if (std::isnan(initialPlaybackPosition)) | 1650 if (std::isnan(initialPlaybackPosition)) |
1652 initialPlaybackPosition = 0; | 1651 initialPlaybackPosition = 0; |
1653 | 1652 |
1654 if (!jumped && initialPlaybackPosition > 0) { | 1653 if (!jumped && initialPlaybackPosition > 0) { |
1655 UseCounter::count(document(), | 1654 UseCounter::count(document(), |
1656 UseCounter::HTMLMediaElementSeekToFragmentStart); | 1655 UseCounter::HTMLMediaElementSeekToFragmentStart); |
1657 seek(initialPlaybackPosition); | 1656 seek(initialPlaybackPosition); |
1658 jumped = true; | 1657 jumped = true; |
1659 } | 1658 } |
1660 | 1659 |
1661 if (mediaControls()) | |
1662 mediaControls()->reset(); | |
1663 if (layoutObject()) | 1660 if (layoutObject()) |
1664 layoutObject()->updateFromElement(); | 1661 layoutObject()->updateFromElement(); |
1665 } | 1662 } |
1666 | 1663 |
1667 bool shouldUpdateDisplayState = false; | 1664 bool shouldUpdateDisplayState = false; |
1668 | 1665 |
1669 if (m_readyState >= kHaveCurrentData && oldState < kHaveCurrentData && | 1666 if (m_readyState >= kHaveCurrentData && oldState < kHaveCurrentData && |
1670 !m_haveFiredLoadedData) { | 1667 !m_haveFiredLoadedData) { |
1671 // Force an update to official playback position to catch non-zero start | 1668 // Force an update to official playback position to catch non-zero start |
1672 // times that were not known at kHaveMetadata, but are known now that the | 1669 // times that were not known at kHaveMetadata, but are known now that the |
(...skipping 2172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3845 | 3842 |
3846 bool HTMLMediaElement::isAutoplayAllowedPerSettings() const { | 3843 bool HTMLMediaElement::isAutoplayAllowedPerSettings() const { |
3847 LocalFrame* frame = document().frame(); | 3844 LocalFrame* frame = document().frame(); |
3848 if (!frame) | 3845 if (!frame) |
3849 return false; | 3846 return false; |
3850 FrameLoaderClient* frameLoaderClient = frame->loader().client(); | 3847 FrameLoaderClient* frameLoaderClient = frame->loader().client(); |
3851 return frameLoaderClient && frameLoaderClient->allowAutoplay(false); | 3848 return frameLoaderClient && frameLoaderClient->allowAutoplay(false); |
3852 } | 3849 } |
3853 | 3850 |
3854 void HTMLMediaElement::setNetworkState(NetworkState state) { | 3851 void HTMLMediaElement::setNetworkState(NetworkState state) { |
3855 if (m_networkState != state) { | 3852 if (m_networkState == state) |
3856 m_networkState = state; | 3853 return; |
3857 if (MediaControls* controls = mediaControls()) | 3854 |
3858 controls->networkStateChanged(); | 3855 m_networkState = state; |
3859 } | 3856 if (mediaControls()) |
3857 mediaControls()->networkStateChanged(); | |
3860 } | 3858 } |
3861 | 3859 |
3862 void HTMLMediaElement::videoWillBeDrawnToCanvas() const { | 3860 void HTMLMediaElement::videoWillBeDrawnToCanvas() const { |
3863 DCHECK(isHTMLVideoElement()); | 3861 DCHECK(isHTMLVideoElement()); |
3864 UseCounter::count(document(), UseCounter::VideoInCanvas); | 3862 UseCounter::count(document(), UseCounter::VideoInCanvas); |
3865 if (m_autoplayUmaHelper->hasSource() && !m_autoplayUmaHelper->isVisible()) | 3863 if (m_autoplayUmaHelper->hasSource() && !m_autoplayUmaHelper->isVisible()) |
3866 UseCounter::count(document(), UseCounter::HiddenAutoplayedVideoInCanvas); | 3864 UseCounter::count(document(), UseCounter::HiddenAutoplayedVideoInCanvas); |
3867 } | 3865 } |
3868 | 3866 |
3869 void HTMLMediaElement::scheduleResolvePlayPromises() { | 3867 void HTMLMediaElement::scheduleResolvePlayPromises() { |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4103 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); | 4101 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); |
4104 } | 4102 } |
4105 | 4103 |
4106 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) { | 4104 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) { |
4107 m_mostlyFillingViewport = true; | 4105 m_mostlyFillingViewport = true; |
4108 if (m_webMediaPlayer) | 4106 if (m_webMediaPlayer) |
4109 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport); | 4107 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport); |
4110 } | 4108 } |
4111 | 4109 |
4112 } // namespace blink | 4110 } // namespace blink |
OLD | NEW |