Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "core/html/HTMLMediaElement.h" | 26 #include "core/html/HTMLMediaElement.h" |
| 27 | 27 |
| 28 #include "bindings/core/v8/ExceptionState.h" | 28 #include "bindings/core/v8/ExceptionState.h" |
| 29 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 29 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 30 #include "bindings/core/v8/ScriptController.h" | 30 #include "bindings/core/v8/ScriptController.h" |
| 31 #include "bindings/core/v8/ScriptEventListener.h" | 31 #include "bindings/core/v8/ScriptEventListener.h" |
| 32 #include "bindings/core/v8/ScriptPromiseResolver.h" | |
| 32 #include "core/HTMLNames.h" | 33 #include "core/HTMLNames.h" |
| 33 #include "core/css/MediaList.h" | 34 #include "core/css/MediaList.h" |
| 34 #include "core/dom/Attribute.h" | 35 #include "core/dom/Attribute.h" |
| 35 #include "core/dom/ElementTraversal.h" | 36 #include "core/dom/ElementTraversal.h" |
| 36 #include "core/dom/ExceptionCode.h" | 37 #include "core/dom/ExceptionCode.h" |
| 37 #include "core/dom/Fullscreen.h" | 38 #include "core/dom/Fullscreen.h" |
| 38 #include "core/dom/shadow/ShadowRoot.h" | 39 #include "core/dom/shadow/ShadowRoot.h" |
| 39 #include "core/events/Event.h" | 40 #include "core/events/Event.h" |
| 40 #include "core/frame/LocalFrame.h" | 41 #include "core/frame/LocalFrame.h" |
| 41 #include "core/frame/Settings.h" | 42 #include "core/frame/Settings.h" |
| 42 #include "core/frame/UseCounter.h" | 43 #include "core/frame/UseCounter.h" |
| 43 #include "core/frame/csp/ContentSecurityPolicy.h" | 44 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 44 #include "core/html/HTMLMediaSource.h" | 45 #include "core/html/HTMLMediaSource.h" |
| 45 #include "core/html/HTMLSourceElement.h" | 46 #include "core/html/HTMLSourceElement.h" |
| 46 #include "core/html/HTMLTrackElement.h" | 47 #include "core/html/HTMLTrackElement.h" |
| 47 #include "core/html/MediaError.h" | |
| 48 #include "core/html/MediaFragmentURIParser.h" | 48 #include "core/html/MediaFragmentURIParser.h" |
| 49 #include "core/html/TimeRanges.h" | 49 #include "core/html/TimeRanges.h" |
| 50 #include "core/html/shadow/MediaControls.h" | 50 #include "core/html/shadow/MediaControls.h" |
| 51 #include "core/html/track/AudioTrack.h" | 51 #include "core/html/track/AudioTrack.h" |
| 52 #include "core/html/track/AudioTrackList.h" | 52 #include "core/html/track/AudioTrackList.h" |
| 53 #include "core/html/track/AutomaticTrackSelection.h" | 53 #include "core/html/track/AutomaticTrackSelection.h" |
| 54 #include "core/html/track/CueTimeline.h" | 54 #include "core/html/track/CueTimeline.h" |
| 55 #include "core/html/track/InbandTextTrack.h" | 55 #include "core/html/track/InbandTextTrack.h" |
| 56 #include "core/html/track/TextTrackContainer.h" | 56 #include "core/html/track/TextTrackContainer.h" |
| 57 #include "core/html/track/TextTrackList.h" | 57 #include "core/html/track/TextTrackList.h" |
| 58 #include "core/html/track/VideoTrack.h" | 58 #include "core/html/track/VideoTrack.h" |
| 59 #include "core/html/track/VideoTrackList.h" | 59 #include "core/html/track/VideoTrackList.h" |
| 60 #include "core/inspector/ConsoleMessage.h" | 60 #include "core/inspector/ConsoleMessage.h" |
| 61 #include "core/layout/LayoutVideo.h" | 61 #include "core/layout/LayoutVideo.h" |
| 62 #include "core/layout/LayoutView.h" | 62 #include "core/layout/LayoutView.h" |
| 63 #include "core/layout/compositing/PaintLayerCompositor.h" | 63 #include "core/layout/compositing/PaintLayerCompositor.h" |
| 64 #include "core/loader/FrameLoader.h" | 64 #include "core/loader/FrameLoader.h" |
| 65 #include "core/loader/FrameLoaderClient.h" | 65 #include "core/loader/FrameLoaderClient.h" |
| 66 #include "core/page/ChromeClient.h" | 66 #include "core/page/ChromeClient.h" |
| 67 #include "core/page/NetworkStateNotifier.h" | 67 #include "core/page/NetworkStateNotifier.h" |
| 68 #include "platform/ContentType.h" | 68 #include "platform/ContentType.h" |
| 69 #include "platform/Logging.h" | 69 #include "platform/Logging.h" |
| 70 #include "platform/MIMETypeFromURL.h" | 70 #include "platform/MIMETypeFromURL.h" |
| 71 #include "platform/MIMETypeRegistry.h" | 71 #include "platform/MIMETypeRegistry.h" |
| 72 #include "platform/RuntimeEnabledFeatures.h" | 72 #include "platform/RuntimeEnabledFeatures.h" |
| 73 #include "platform/Task.h" | |
| 73 #include "platform/UserGestureIndicator.h" | 74 #include "platform/UserGestureIndicator.h" |
| 74 #include "platform/audio/AudioBus.h" | 75 #include "platform/audio/AudioBus.h" |
| 75 #include "platform/audio/AudioSourceProviderClient.h" | 76 #include "platform/audio/AudioSourceProviderClient.h" |
| 76 #include "platform/graphics/GraphicsLayer.h" | 77 #include "platform/graphics/GraphicsLayer.h" |
| 77 #include "platform/weborigin/SecurityOrigin.h" | 78 #include "platform/weborigin/SecurityOrigin.h" |
| 78 #include "public/platform/Platform.h" | 79 #include "public/platform/Platform.h" |
| 79 #include "public/platform/WebAudioSourceProvider.h" | 80 #include "public/platform/WebAudioSourceProvider.h" |
| 80 #include "public/platform/WebContentDecryptionModule.h" | 81 #include "public/platform/WebContentDecryptionModule.h" |
| 81 #include "public/platform/WebInbandTextTrack.h" | 82 #include "public/platform/WebInbandTextTrack.h" |
| 82 #include "wtf/CurrentTime.h" | 83 #include "wtf/CurrentTime.h" |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 719 m_displayMode = Unknown; | 720 m_displayMode = Unknown; |
| 720 | 721 |
| 721 // 1 - Abort any already-running instance of the resource selection algorith m for this element. | 722 // 1 - Abort any already-running instance of the resource selection algorith m for this element. |
| 722 m_loadState = WaitingForSource; | 723 m_loadState = WaitingForSource; |
| 723 m_currentSourceNode = nullptr; | 724 m_currentSourceNode = nullptr; |
| 724 | 725 |
| 725 // 2 - If there are any tasks from the media element's media element event t ask source in | 726 // 2 - If there are any tasks from the media element's media element event t ask source in |
| 726 // one of the task queues, then remove those tasks. | 727 // one of the task queues, then remove those tasks. |
| 727 cancelPendingEventsAndCallbacks(); | 728 cancelPendingEventsAndCallbacks(); |
| 728 | 729 |
| 730 rejectPlayPromises(MediaError::MEDIA_ERR_ABORTED); | |
| 731 | |
| 729 // 3 - If the media element's networkState is set to NETWORK_LOADING or NETW ORK_IDLE, queue | 732 // 3 - If the media element's networkState is set to NETWORK_LOADING or NETW ORK_IDLE, queue |
| 730 // a task to fire a simple event named abort at the media element. | 733 // a task to fire a simple event named abort at the media element. |
| 731 if (m_networkState == NETWORK_LOADING || m_networkState == NETWORK_IDLE) | 734 if (m_networkState == NETWORK_LOADING || m_networkState == NETWORK_IDLE) |
| 732 scheduleEvent(EventTypeNames::abort); | 735 scheduleEvent(EventTypeNames::abort); |
| 733 | 736 |
| 734 resetMediaPlayerAndMediaSource(); | 737 resetMediaPlayerAndMediaSource(); |
| 735 | 738 |
| 736 // 4 - If the media element's networkState is not set to NETWORK_EMPTY, then run these substeps | 739 // 4 - If the media element's networkState is not set to NETWORK_EMPTY, then run these substeps |
| 737 if (m_networkState != NETWORK_EMPTY) { | 740 if (m_networkState != NETWORK_EMPTY) { |
| 738 // 4.1 - Queue a task to fire a simple event named emptied at the media element. | 741 // 4.1 - Queue a task to fire a simple event named emptied at the media element. |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1247 // 6.1 - Set the error attribute to a new MediaError object whose code attri bute is set to | 1250 // 6.1 - Set the error attribute to a new MediaError object whose code attri bute is set to |
| 1248 // MEDIA_ERR_SRC_NOT_SUPPORTED. | 1251 // MEDIA_ERR_SRC_NOT_SUPPORTED. |
| 1249 m_error = MediaError::create(MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED); | 1252 m_error = MediaError::create(MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED); |
| 1250 | 1253 |
| 1251 // 6.2 - Forget the media element's media-resource-specific text tracks. | 1254 // 6.2 - Forget the media element's media-resource-specific text tracks. |
| 1252 forgetResourceSpecificTracks(); | 1255 forgetResourceSpecificTracks(); |
| 1253 | 1256 |
| 1254 // 6.3 - Set the element's networkState attribute to the NETWORK_NO_SOURCE v alue. | 1257 // 6.3 - Set the element's networkState attribute to the NETWORK_NO_SOURCE v alue. |
| 1255 setNetworkState(NETWORK_NO_SOURCE); | 1258 setNetworkState(NETWORK_NO_SOURCE); |
| 1256 | 1259 |
| 1257 // 7 - Queue a task to fire a simple event named error at the media element. | 1260 // 5 - Queue a task to fire a simple event named error at the media element. |
| 1258 scheduleEvent(EventTypeNames::error); | 1261 scheduleEvent(EventTypeNames::error); |
| 1259 | 1262 |
| 1263 // 6 - For each promise in the list of pending play romises, reject it with NotSupportedError. | |
|
philipj_slow
2016/02/02 09:56:33
Can you sweep your CL and update step numbers and
mlamouri (slow - plz ping)
2016/02/03 19:28:57
Done.
| |
| 1264 scheduleRejectPlayPromises(MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED); | |
| 1265 | |
| 1260 closeMediaSource(); | 1266 closeMediaSource(); |
| 1261 | 1267 |
| 1262 // 8 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. | 1268 // 7 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. |
| 1263 setShouldDelayLoadEvent(false); | 1269 setShouldDelayLoadEvent(false); |
| 1264 | 1270 |
| 1265 // 9 - Abort these steps. Until the load() method is invoked or the src attr ibute is changed, | 1271 // 9 - Abort these steps. Until the load() method is invoked or the src attr ibute is changed, |
| 1266 // the element won't attempt to load another resource. | 1272 // the element won't attempt to load another resource. |
| 1267 | 1273 |
| 1268 updateDisplayState(); | 1274 updateDisplayState(); |
| 1269 | 1275 |
| 1270 if (layoutObject()) | 1276 if (layoutObject()) |
| 1271 layoutObject()->updateFromElement(); | 1277 layoutObject()->updateFromElement(); |
| 1272 } | 1278 } |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1510 m_haveFiredLoadedData = true; | 1516 m_haveFiredLoadedData = true; |
| 1511 shouldUpdateDisplayState = true; | 1517 shouldUpdateDisplayState = true; |
| 1512 scheduleEvent(EventTypeNames::loadeddata); | 1518 scheduleEvent(EventTypeNames::loadeddata); |
| 1513 setShouldDelayLoadEvent(false); | 1519 setShouldDelayLoadEvent(false); |
| 1514 } | 1520 } |
| 1515 | 1521 |
| 1516 bool isPotentiallyPlaying = potentiallyPlaying(); | 1522 bool isPotentiallyPlaying = potentiallyPlaying(); |
| 1517 if (m_readyState == HAVE_FUTURE_DATA && oldState <= HAVE_CURRENT_DATA && tra cksAreReady) { | 1523 if (m_readyState == HAVE_FUTURE_DATA && oldState <= HAVE_CURRENT_DATA && tra cksAreReady) { |
| 1518 scheduleEvent(EventTypeNames::canplay); | 1524 scheduleEvent(EventTypeNames::canplay); |
| 1519 if (isPotentiallyPlaying) | 1525 if (isPotentiallyPlaying) |
| 1520 scheduleEvent(EventTypeNames::playing); | 1526 scheduleNotifyPlaying(); |
| 1521 shouldUpdateDisplayState = true; | 1527 shouldUpdateDisplayState = true; |
| 1522 } | 1528 } |
| 1523 | 1529 |
| 1524 if (m_readyState == HAVE_ENOUGH_DATA && oldState < HAVE_ENOUGH_DATA && track sAreReady) { | 1530 if (m_readyState == HAVE_ENOUGH_DATA && oldState < HAVE_ENOUGH_DATA && track sAreReady) { |
| 1525 if (oldState <= HAVE_CURRENT_DATA) { | 1531 if (oldState <= HAVE_CURRENT_DATA) { |
| 1526 scheduleEvent(EventTypeNames::canplay); | 1532 scheduleEvent(EventTypeNames::canplay); |
| 1527 if (isPotentiallyPlaying) | 1533 if (isPotentiallyPlaying) |
| 1528 scheduleEvent(EventTypeNames::playing); | 1534 scheduleNotifyPlaying(); |
| 1529 } | 1535 } |
| 1530 | 1536 |
| 1531 // Check for autoplay, and record metrics about it if needed. | 1537 // Check for autoplay, and record metrics about it if needed. |
| 1532 if (shouldAutoplay(RecordMetricsBehavior::DoRecord)) { | 1538 if (shouldAutoplay(RecordMetricsBehavior::DoRecord)) { |
| 1533 // If the autoplay experiment says that it's okay to play now, | 1539 // If the autoplay experiment says that it's okay to play now, |
| 1534 // then don't require a user gesture. | 1540 // then don't require a user gesture. |
| 1535 m_autoplayHelper.becameReadyToPlay(); | 1541 m_autoplayHelper.becameReadyToPlay(); |
| 1536 | 1542 |
| 1537 if (!m_userGestureRequiredForPlay) { | 1543 if (!m_userGestureRequiredForPlay) { |
| 1538 m_paused = false; | 1544 m_paused = false; |
| 1539 invalidateCachedTime(); | 1545 invalidateCachedTime(); |
| 1540 scheduleEvent(EventTypeNames::play); | 1546 scheduleEvent(EventTypeNames::play); |
| 1541 scheduleEvent(EventTypeNames::playing); | 1547 scheduleNotifyPlaying(); |
| 1542 m_autoplaying = false; | 1548 m_autoplaying = false; |
| 1543 } | 1549 } |
| 1544 } | 1550 } |
| 1545 | 1551 |
| 1546 scheduleEvent(EventTypeNames::canplaythrough); | 1552 scheduleEvent(EventTypeNames::canplaythrough); |
| 1547 | 1553 |
| 1548 shouldUpdateDisplayState = true; | 1554 shouldUpdateDisplayState = true; |
| 1549 } | 1555 } |
| 1550 | 1556 |
| 1551 if (shouldUpdateDisplayState) { | 1557 if (shouldUpdateDisplayState) { |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1923 // https://crbug.com/310450 | 1929 // https://crbug.com/310450 |
| 1924 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadDefault); | 1930 UseCounter::count(document(), UseCounter::HTMLMediaElementPreloadDefault); |
| 1925 return WebMediaPlayer::PreloadAuto; | 1931 return WebMediaPlayer::PreloadAuto; |
| 1926 } | 1932 } |
| 1927 | 1933 |
| 1928 WebMediaPlayer::Preload HTMLMediaElement::effectivePreloadType() const | 1934 WebMediaPlayer::Preload HTMLMediaElement::effectivePreloadType() const |
| 1929 { | 1935 { |
| 1930 return autoplay() ? WebMediaPlayer::PreloadAuto : preloadType(); | 1936 return autoplay() ? WebMediaPlayer::PreloadAuto : preloadType(); |
| 1931 } | 1937 } |
| 1932 | 1938 |
| 1933 void HTMLMediaElement::play() | 1939 ScriptPromise HTMLMediaElement::play(ScriptState* scriptState) |
| 1934 { | 1940 { |
| 1935 WTF_LOG(Media, "HTMLMediaElement::play(%p)", this); | 1941 WTF_LOG(Media, "HTMLMediaElement::play(%p)", this); |
| 1936 | 1942 |
| 1937 m_autoplayHelper.playMethodCalled(); | 1943 m_autoplayHelper.playMethodCalled(); |
| 1938 | 1944 |
| 1939 if (!UserGestureIndicator::processingUserGesture()) { | 1945 if (!UserGestureIndicator::processingUserGesture()) { |
| 1940 autoplayMediaEncountered(); | 1946 autoplayMediaEncountered(); |
| 1941 | 1947 |
| 1942 if (m_userGestureRequiredForPlay) { | 1948 if (m_userGestureRequiredForPlay) { |
| 1943 recordAutoplayMetric(PlayMethodFailed); | 1949 recordAutoplayMetric(PlayMethodFailed); |
| 1944 String message = ExceptionMessages::failedToExecute("play", "HTMLMed iaElement", "API can only be initiated by a user gesture."); | 1950 String message = ExceptionMessages::failedToExecute("play", "HTMLMed iaElement", "API can only be initiated by a user gesture."); |
| 1945 document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message)); | 1951 document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message)); |
| 1946 return; | 1952 return ScriptPromise::rejectWithDOMException(scriptState, DOMExcepti on::create(NotAllowedError, "play() must be initiated by a user gesture.")); |
| 1947 } | 1953 } |
| 1948 } else if (m_userGestureRequiredForPlay) { | 1954 } else if (m_userGestureRequiredForPlay) { |
| 1949 if (m_autoplayMediaCounted) | 1955 if (m_autoplayMediaCounted) |
| 1950 recordAutoplayMetric(AutoplayManualStart); | 1956 recordAutoplayMetric(AutoplayManualStart); |
| 1951 m_userGestureRequiredForPlay = false; | 1957 m_userGestureRequiredForPlay = false; |
| 1952 } | 1958 } |
| 1953 | 1959 |
| 1960 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; | |
| 1961 ScriptPromise promise = resolver->promise(); | |
| 1962 | |
| 1963 m_playResolvers.append(resolver); | |
| 1954 playInternal(); | 1964 playInternal(); |
| 1965 | |
| 1966 return promise; | |
| 1955 } | 1967 } |
| 1956 | 1968 |
| 1957 void HTMLMediaElement::playInternal() | 1969 void HTMLMediaElement::playInternal() |
| 1958 { | 1970 { |
| 1959 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this); | 1971 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this); |
| 1960 | 1972 |
| 1973 if (m_error && m_error->code() == MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED) { | |
|
philipj_slow
2016/02/02 09:56:33
This should be together right after the user gestu
mlamouri (slow - plz ping)
2016/02/03 19:28:57
I don't think there is actually any difference in
philipj_slow
2016/02/04 10:54:20
New structure solves it nicely. I don't think "we
mlamouri (slow - plz ping)
2016/02/18 17:06:06
Done. (for me to keep track)
| |
| 1974 rejectPlayPromises(MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED); | |
| 1975 return; | |
| 1976 } | |
| 1977 | |
| 1961 // Always return the buffering strategy to normal when not paused, | 1978 // Always return the buffering strategy to normal when not paused, |
| 1962 // regardless of the cause. (In contrast with aggressive buffering which is | 1979 // regardless of the cause. (In contrast with aggressive buffering which is |
| 1963 // only enabled by pause(), not pauseInternal().) | 1980 // only enabled by pause(), not pauseInternal().) |
| 1964 if (webMediaPlayer()) | 1981 if (webMediaPlayer()) |
| 1965 webMediaPlayer()->setBufferingStrategy(WebMediaPlayer::BufferingStrategy ::Normal); | 1982 webMediaPlayer()->setBufferingStrategy(WebMediaPlayer::BufferingStrategy ::Normal); |
| 1966 | 1983 |
| 1967 // 4.8.10.9. Playing the media resource | 1984 // 4.8.10.9. Playing the media resource |
| 1968 if (m_networkState == NETWORK_EMPTY) | 1985 if (m_networkState == NETWORK_EMPTY) |
| 1969 scheduleDelayedAction(LoadMediaResource); | 1986 scheduleDelayedAction(LoadMediaResource); |
| 1970 | 1987 |
| 1971 // Generally "ended" and "looping" are exclusive. Here, the loop attribute | 1988 // Generally "ended" and "looping" are exclusive. Here, the loop attribute |
| 1972 // is ignored to seek back to start in case loop was set after playback | 1989 // is ignored to seek back to start in case loop was set after playback |
| 1973 // ended. See http://crbug.com/364442 | 1990 // ended. See http://crbug.com/364442 |
| 1974 if (endedPlayback(LoopCondition::Ignored)) | 1991 if (endedPlayback(LoopCondition::Ignored)) |
| 1975 seek(0); | 1992 seek(0); |
| 1976 | 1993 |
| 1977 if (m_paused) { | 1994 if (m_paused) { |
| 1978 m_paused = false; | 1995 m_paused = false; |
| 1979 invalidateCachedTime(); | 1996 invalidateCachedTime(); |
| 1980 scheduleEvent(EventTypeNames::play); | 1997 scheduleEvent(EventTypeNames::play); |
| 1981 | 1998 |
| 1982 if (m_readyState <= HAVE_CURRENT_DATA) | 1999 if (m_readyState <= HAVE_CURRENT_DATA) |
| 1983 scheduleEvent(EventTypeNames::waiting); | 2000 scheduleEvent(EventTypeNames::waiting); |
| 1984 else if (m_readyState >= HAVE_FUTURE_DATA) | 2001 else if (m_readyState >= HAVE_FUTURE_DATA) |
| 1985 scheduleEvent(EventTypeNames::playing); | 2002 scheduleNotifyPlaying(); |
| 2003 } else if (m_readyState >= HAVE_FUTURE_DATA) { | |
| 2004 scheduleResolvePlayPromises(); | |
| 1986 } | 2005 } |
| 2006 | |
| 1987 m_autoplaying = false; | 2007 m_autoplaying = false; |
| 1988 | 2008 |
| 1989 updatePlayState(); | 2009 updatePlayState(); |
| 1990 } | 2010 } |
| 1991 | 2011 |
| 1992 void HTMLMediaElement::autoplayMediaEncountered() | 2012 void HTMLMediaElement::autoplayMediaEncountered() |
| 1993 { | 2013 { |
| 1994 if (!m_autoplayMediaCounted) { | 2014 if (!m_autoplayMediaCounted) { |
| 1995 m_autoplayMediaCounted = true; | 2015 m_autoplayMediaCounted = true; |
| 1996 recordAutoplayMetric(AutoplayMediaFound); | 2016 recordAutoplayMetric(AutoplayMediaFound); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2031 m_autoplayHelper.pauseMethodCalled(); | 2051 m_autoplayHelper.pauseMethodCalled(); |
| 2032 | 2052 |
| 2033 m_autoplaying = false; | 2053 m_autoplaying = false; |
| 2034 | 2054 |
| 2035 if (!m_paused) { | 2055 if (!m_paused) { |
| 2036 recordMetricsIfPausing(); | 2056 recordMetricsIfPausing(); |
| 2037 | 2057 |
| 2038 m_paused = true; | 2058 m_paused = true; |
| 2039 scheduleTimeupdateEvent(false); | 2059 scheduleTimeupdateEvent(false); |
| 2040 scheduleEvent(EventTypeNames::pause); | 2060 scheduleEvent(EventTypeNames::pause); |
| 2061 scheduleRejectPlayPromises(MediaError::MEDIA_ERR_ABORTED); | |
| 2041 } | 2062 } |
| 2042 | 2063 |
| 2043 updatePlayState(); | 2064 updatePlayState(); |
| 2044 } | 2065 } |
| 2045 | 2066 |
| 2046 void HTMLMediaElement::requestRemotePlayback() | 2067 void HTMLMediaElement::requestRemotePlayback() |
| 2047 { | 2068 { |
| 2048 ASSERT(m_remoteRoutesAvailable); | 2069 ASSERT(m_remoteRoutesAvailable); |
| 2049 webMediaPlayer()->requestRemotePlayback(); | 2070 webMediaPlayer()->requestRemotePlayback(); |
| 2050 } | 2071 } |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2200 if (!periodicEvent || (haveNotRecentlyFiredTimeupdate && movieTimeHasProgres sed)) { | 2221 if (!periodicEvent || (haveNotRecentlyFiredTimeupdate && movieTimeHasProgres sed)) { |
| 2201 scheduleEvent(EventTypeNames::timeupdate); | 2222 scheduleEvent(EventTypeNames::timeupdate); |
| 2202 m_lastTimeUpdateEventWallTime = now; | 2223 m_lastTimeUpdateEventWallTime = now; |
| 2203 m_lastTimeUpdateEventMovieTime = movieTime; | 2224 m_lastTimeUpdateEventMovieTime = movieTime; |
| 2204 } | 2225 } |
| 2205 } | 2226 } |
| 2206 | 2227 |
| 2207 void HTMLMediaElement::togglePlayState() | 2228 void HTMLMediaElement::togglePlayState() |
| 2208 { | 2229 { |
| 2209 if (paused()) | 2230 if (paused()) |
| 2210 play(); | 2231 playInternal(); |
|
philipj_slow
2016/02/02 09:56:33
Hmm, so you don't have a ScriptState here, but if
mlamouri (slow - plz ping)
2016/02/03 19:28:57
Done.
| |
| 2211 else | 2232 else |
| 2212 pause(); | 2233 pause(); |
| 2213 } | 2234 } |
| 2214 | 2235 |
| 2215 AudioTrackList& HTMLMediaElement::audioTracks() | 2236 AudioTrackList& HTMLMediaElement::audioTracks() |
| 2216 { | 2237 { |
| 2217 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | 2238 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
| 2218 return *m_audioTracks; | 2239 return *m_audioTracks; |
| 2219 } | 2240 } |
| 2220 | 2241 |
| (...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3480 visitor->trace(m_asyncEventQueue); | 3501 visitor->trace(m_asyncEventQueue); |
| 3481 visitor->trace(m_error); | 3502 visitor->trace(m_error); |
| 3482 visitor->trace(m_currentSourceNode); | 3503 visitor->trace(m_currentSourceNode); |
| 3483 visitor->trace(m_nextChildNodeToConsider); | 3504 visitor->trace(m_nextChildNodeToConsider); |
| 3484 visitor->trace(m_mediaSource); | 3505 visitor->trace(m_mediaSource); |
| 3485 visitor->trace(m_audioTracks); | 3506 visitor->trace(m_audioTracks); |
| 3486 visitor->trace(m_videoTracks); | 3507 visitor->trace(m_videoTracks); |
| 3487 visitor->trace(m_cueTimeline); | 3508 visitor->trace(m_cueTimeline); |
| 3488 visitor->trace(m_textTracks); | 3509 visitor->trace(m_textTracks); |
| 3489 visitor->trace(m_textTracksWhenResourceSelectionBegan); | 3510 visitor->trace(m_textTracksWhenResourceSelectionBegan); |
| 3511 visitor->trace(m_playResolvers); | |
| 3490 visitor->trace(m_audioSourceProvider); | 3512 visitor->trace(m_audioSourceProvider); |
| 3491 visitor->template registerWeakMembers<HTMLMediaElement, &HTMLMediaElement::c learWeakMembers>(this); | 3513 visitor->template registerWeakMembers<HTMLMediaElement, &HTMLMediaElement::c learWeakMembers>(this); |
| 3492 visitor->trace(m_autoplayHelper); | 3514 visitor->trace(m_autoplayHelper); |
| 3493 HeapSupplementable<HTMLMediaElement>::trace(visitor); | 3515 HeapSupplementable<HTMLMediaElement>::trace(visitor); |
| 3494 #endif | 3516 #endif |
| 3495 HTMLElement::trace(visitor); | 3517 HTMLElement::trace(visitor); |
| 3496 ActiveDOMObject::trace(visitor); | 3518 ActiveDOMObject::trace(visitor); |
| 3497 } | 3519 } |
| 3498 | 3520 |
| 3499 void HTMLMediaElement::createPlaceholderTracksIfNecessary() | 3521 void HTMLMediaElement::createPlaceholderTracksIfNecessary() |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3557 { | 3579 { |
| 3558 m_autoplayHelper.updatePositionNotificationRegistration(); | 3580 m_autoplayHelper.updatePositionNotificationRegistration(); |
| 3559 } | 3581 } |
| 3560 | 3582 |
| 3561 // TODO(liberato): remove once autoplay gesture override experiment concludes. | 3583 // TODO(liberato): remove once autoplay gesture override experiment concludes. |
| 3562 void HTMLMediaElement::triggerAutoplayViewportCheckForTesting() | 3584 void HTMLMediaElement::triggerAutoplayViewportCheckForTesting() |
| 3563 { | 3585 { |
| 3564 m_autoplayHelper.triggerAutoplayViewportCheckForTesting(); | 3586 m_autoplayHelper.triggerAutoplayViewportCheckForTesting(); |
| 3565 } | 3587 } |
| 3566 | 3588 |
| 3589 void HTMLMediaElement::scheduleResolvePlayPromises() | |
| 3590 { | |
| 3591 Platform::current()->currentThread()->taskRunner()->postTask( | |
| 3592 BLINK_FROM_HERE, new Task(WTF::bind(&HTMLMediaElement::resolvePlayPromis es, this))); | |
|
philipj_slow
2016/02/02 09:56:33
So this is much nicer than the Timer thing used el
mlamouri (slow - plz ping)
2016/02/03 19:28:57
I do not know how oilpan would handle that. Worth
philipj_slow
2016/02/04 10:54:20
Please do, this looks like a potential crash.
mlamouri (slow - plz ping)
2016/02/18 17:06:06
I asked haraken@. He gave me a hint and I'm adding
| |
| 3593 } | |
| 3594 | |
| 3595 void HTMLMediaElement::scheduleRejectPlayPromises(MediaError::Code errorCode) | |
| 3596 { | |
| 3597 Platform::current()->currentThread()->taskRunner()->postTask( | |
| 3598 BLINK_FROM_HERE, new Task(WTF::bind(&HTMLMediaElement::rejectPlayPromise s, this, errorCode))); | |
| 3599 } | |
| 3600 | |
| 3601 void HTMLMediaElement::scheduleNotifyPlaying() | |
| 3602 { | |
| 3603 scheduleEvent(EventTypeNames::playing); | |
|
philipj_slow
2016/02/02 09:56:33
https://html.spec.whatwg.org/#notify-about-playing
mlamouri (slow - plz ping)
2016/02/03 19:28:57
AFAICT, with the current infra we have in Blink, w
philipj_slow
2016/02/04 10:54:20
It is indeed hard to fix without revamping the med
mlamouri (slow - plz ping)
2016/02/18 17:06:06
Done.
| |
| 3604 scheduleResolvePlayPromises(); | |
| 3605 } | |
| 3606 | |
| 3607 void HTMLMediaElement::resolvePlayPromises() | |
| 3608 { | |
| 3609 for (auto& resolver: m_playResolvers) | |
| 3610 resolver->resolve(); | |
| 3611 | |
| 3612 m_playResolvers.clear(); | |
| 3613 } | |
| 3614 | |
| 3615 void HTMLMediaElement::rejectPlayPromises(MediaError::Code errorCode) | |
| 3616 { | |
| 3617 ExceptionCode code; | |
| 3618 String message; | |
| 3619 | |
| 3620 switch (errorCode) { | |
| 3621 case MediaError::MEDIA_ERR_ABORTED: | |
| 3622 code = AbortError; | |
| 3623 message = "The play() command was interrupted by another command like lo ad() or pause()."; | |
|
philipj_slow
2016/02/02 09:56:33
I think it'd be best to just pass code and message
mlamouri (slow - plz ping)
2016/02/03 19:28:57
Done.
| |
| 3624 break; | |
| 3625 case MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED: | |
| 3626 code = NotSupportedError; | |
| 3627 message = "Failed to load because no supported source was found."; | |
|
philipj_slow
2016/02/02 09:56:33
It would be good to split this too, to distinguish
mlamouri (slow - plz ping)
2016/02/03 19:28:57
Done.
| |
| 3628 break; | |
| 3629 case MediaError::MEDIA_ERR_DECODE: | |
| 3630 case MediaError::MEDIA_ERR_NETWORK: | |
| 3631 ASSERT_NOT_REACHED(); | |
| 3632 break; | |
| 3633 } | |
| 3634 | |
| 3635 for (auto& resolver: m_playResolvers) | |
| 3636 resolver->reject(DOMException::create(code, message)); | |
| 3637 | |
| 3638 m_playResolvers.clear(); | |
| 3639 } | |
| 3640 | |
| 3567 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 3641 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
| 3568 { | 3642 { |
| 3569 if (!Heap::isHeapObjectAlive(m_audioSourceNode)) | 3643 if (!Heap::isHeapObjectAlive(m_audioSourceNode)) |
| 3570 audioSourceProvider().setClient(nullptr); | 3644 audioSourceProvider().setClient(nullptr); |
| 3571 } | 3645 } |
| 3572 | 3646 |
| 3573 void HTMLMediaElement::AudioSourceProviderImpl::wrap(WebAudioSourceProvider* pro vider) | 3647 void HTMLMediaElement::AudioSourceProviderImpl::wrap(WebAudioSourceProvider* pro vider) |
| 3574 { | 3648 { |
| 3575 MutexLocker locker(provideInputLock); | 3649 MutexLocker locker(provideInputLock); |
| 3576 | 3650 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3624 { | 3698 { |
| 3625 visitor->trace(m_client); | 3699 visitor->trace(m_client); |
| 3626 } | 3700 } |
| 3627 | 3701 |
| 3628 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) | 3702 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) |
| 3629 { | 3703 { |
| 3630 visitor->trace(m_client); | 3704 visitor->trace(m_client); |
| 3631 } | 3705 } |
| 3632 | 3706 |
| 3633 } // namespace blink | 3707 } // namespace blink |
| OLD | NEW |