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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 , m_lastSeekTime(0) | 307 , m_lastSeekTime(0) |
308 , m_previousProgressTime(std::numeric_limits<double>::max()) | 308 , m_previousProgressTime(std::numeric_limits<double>::max()) |
309 , m_duration(std::numeric_limits<double>::quiet_NaN()) | 309 , m_duration(std::numeric_limits<double>::quiet_NaN()) |
310 , m_lastTimeUpdateEventWallTime(0) | 310 , m_lastTimeUpdateEventWallTime(0) |
311 , m_lastTimeUpdateEventMovieTime(0) | 311 , m_lastTimeUpdateEventMovieTime(0) |
312 , m_defaultPlaybackStartPosition(0) | 312 , m_defaultPlaybackStartPosition(0) |
313 , m_loadState(WaitingForSource) | 313 , m_loadState(WaitingForSource) |
314 , m_deferredLoadState(NotDeferred) | 314 , m_deferredLoadState(NotDeferred) |
315 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) | 315 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) |
316 , m_webLayer(nullptr) | 316 , m_webLayer(nullptr) |
317 , m_displayMode(Unknown) | |
318 , m_cachedTime(std::numeric_limits<double>::quiet_NaN()) | 317 , m_cachedTime(std::numeric_limits<double>::quiet_NaN()) |
319 , m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN()) | 318 , m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN()) |
320 , m_pendingActionFlags(0) | 319 , m_pendingActionFlags(0) |
321 , m_userGestureRequiredForPlay(false) | 320 , m_userGestureRequiredForPlay(false) |
322 , m_playing(false) | 321 , m_playing(false) |
323 , m_shouldDelayLoadEvent(false) | 322 , m_shouldDelayLoadEvent(false) |
324 , m_haveFiredLoadedData(false) | 323 , m_haveFiredLoadedData(false) |
325 , m_autoplaying(true) | 324 , m_autoplaying(true) |
326 , m_muted(false) | 325 , m_muted(false) |
327 , m_paused(true) | 326 , m_paused(true) |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 stopPeriodicTimers(); | 729 stopPeriodicTimers(); |
731 m_loadTimer.stop(); | 730 m_loadTimer.stop(); |
732 cancelDeferredLoad(); | 731 cancelDeferredLoad(); |
733 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec
essary and set m_pendingActionFlags to 0 here. | 732 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec
essary and set m_pendingActionFlags to 0 here. |
734 m_pendingActionFlags &= ~LoadMediaResource; | 733 m_pendingActionFlags &= ~LoadMediaResource; |
735 m_sentEndEvent = false; | 734 m_sentEndEvent = false; |
736 m_sentStalledEvent = false; | 735 m_sentStalledEvent = false; |
737 m_haveFiredLoadedData = false; | 736 m_haveFiredLoadedData = false; |
738 m_completelyLoaded = false; | 737 m_completelyLoaded = false; |
739 m_havePreparedToPlay = false; | 738 m_havePreparedToPlay = false; |
740 m_displayMode = Unknown; | |
741 | 739 |
742 // 1 - Abort any already-running instance of the resource selection algorith
m for this element. | 740 // 1 - Abort any already-running instance of the resource selection algorith
m for this element. |
743 m_loadState = WaitingForSource; | 741 m_loadState = WaitingForSource; |
744 m_currentSourceNode = nullptr; | 742 m_currentSourceNode = nullptr; |
745 | 743 |
746 // 2 - If there are any tasks from the media element's media element event t
ask source in | 744 // 2 - If there are any tasks from the media element's media element event t
ask source in |
747 // one of the task queues, then remove those tasks. | 745 // one of the task queues, then remove those tasks. |
748 cancelPendingEventsAndCallbacks(); | 746 cancelPendingEventsAndCallbacks(); |
749 | 747 |
750 // 3 - If the media element's networkState is set to NETWORK_LOADING or NETW
ORK_IDLE, queue | 748 // 3 - If the media element's networkState is set to NETWORK_LOADING or NETW
ORK_IDLE, queue |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 | 795 |
798 // 6 - Set the error attribute to null and the autoplaying flag to true. | 796 // 6 - Set the error attribute to null and the autoplaying flag to true. |
799 m_error = nullptr; | 797 m_error = nullptr; |
800 m_autoplaying = true; | 798 m_autoplaying = true; |
801 | 799 |
802 // 7 - Invoke the media element's resource selection algorithm. | 800 // 7 - Invoke the media element's resource selection algorithm. |
803 | 801 |
804 // 8 - Note: Playback of any previously playing media resource for this elem
ent stops. | 802 // 8 - Note: Playback of any previously playing media resource for this elem
ent stops. |
805 | 803 |
806 // The resource selection algorithm | 804 // The resource selection algorithm |
807 // 1 - Set the networkState to NETWORK_NO_SOURCE | 805 // 1 - Set the element's networkState attribute to the NETWORK_NO_SOURCE val
ue. |
808 m_networkState = NETWORK_NO_SOURCE; | 806 m_networkState = NETWORK_NO_SOURCE; |
809 | 807 |
810 // 2 - Asynchronously await a stable state. | 808 // 2 - Set the element's show poster flag to true. |
| 809 setShowPoster(true); |
811 | 810 |
812 m_playedTimeRanges = TimeRanges::create(); | 811 m_playedTimeRanges = TimeRanges::create(); |
813 | 812 |
814 // FIXME: Investigate whether these can be moved into m_networkState != NETW
ORK_EMPTY block above | 813 // FIXME: Investigate whether these can be moved into m_networkState != NETW
ORK_EMPTY block above |
815 // so they are closer to the relevant spec steps. | 814 // so they are closer to the relevant spec steps. |
816 m_lastSeekTime = 0; | 815 m_lastSeekTime = 0; |
817 m_duration = std::numeric_limits<double>::quiet_NaN(); | 816 m_duration = std::numeric_limits<double>::quiet_NaN(); |
818 | 817 |
819 // The spec doesn't say to block the load event until we actually run the as
ynchronous section | 818 // 3 - Set the media element's delaying-the-load-event flag to true (this de
lays the load event). |
820 // algorithm, but do it now because we won't start that until after the time
r fires and the | |
821 // event may have already fired by then. | |
822 setShouldDelayLoadEvent(true); | 819 setShouldDelayLoadEvent(true); |
823 if (mediaControls()) | 820 if (mediaControls()) |
824 mediaControls()->reset(); | 821 mediaControls()->reset(); |
| 822 |
| 823 // 4 - Await a stable state, allowing the task that invoked this algorithm t
o continue. |
825 } | 824 } |
826 | 825 |
827 void HTMLMediaElement::loadInternal() | 826 void HTMLMediaElement::loadInternal() |
828 { | 827 { |
829 // HTMLMediaElement::textTracksAreReady will need "... the text tracks whose
mode was not in the | 828 // HTMLMediaElement::textTracksAreReady will need "... the text tracks whose
mode was not in the |
830 // disabled state when the element's resource selection algorithm last start
ed". | 829 // disabled state when the element's resource selection algorithm last start
ed". |
831 m_textTracksWhenResourceSelectionBegan.clear(); | 830 m_textTracksWhenResourceSelectionBegan.clear(); |
832 if (m_textTracks) { | 831 if (m_textTracks) { |
833 for (unsigned i = 0; i < m_textTracks->length(); ++i) { | 832 for (unsigned i = 0; i < m_textTracks->length(); ++i) { |
834 TextTrack* track = m_textTracks->item(i); | 833 TextTrack* track = m_textTracks->item(i); |
(...skipping 21 matching lines...) Expand all Loading... |
856 mode = children; | 855 mode = children; |
857 m_nextChildNodeToConsider = element; | 856 m_nextChildNodeToConsider = element; |
858 m_currentSourceNode = nullptr; | 857 m_currentSourceNode = nullptr; |
859 } else { | 858 } else { |
860 // Otherwise the media element has neither a src attribute nor a sou
rce element | 859 // Otherwise the media element has neither a src attribute nor a sou
rce element |
861 // child: set the networkState to NETWORK_EMPTY, and abort these ste
ps; the | 860 // child: set the networkState to NETWORK_EMPTY, and abort these ste
ps; the |
862 // synchronous section ends. | 861 // synchronous section ends. |
863 m_loadState = WaitingForSource; | 862 m_loadState = WaitingForSource; |
864 setShouldDelayLoadEvent(false); | 863 setShouldDelayLoadEvent(false); |
865 m_networkState = NETWORK_EMPTY; | 864 m_networkState = NETWORK_EMPTY; |
866 updateDisplayState(); | |
867 | 865 |
868 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), nothing t
o load", this); | 866 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), nothing t
o load", this); |
869 return; | 867 return; |
870 } | 868 } |
871 } | 869 } |
872 | 870 |
873 // 4 - Set the media element's delaying-the-load-event flag to true (this de
lays the load event), | 871 // 4 - Set the media element's delaying-the-load-event flag to true (this de
lays the load event), |
874 // and set its networkState to NETWORK_LOADING. | 872 // and set its networkState to NETWORK_LOADING. |
875 setShouldDelayLoadEvent(true); | 873 setShouldDelayLoadEvent(true); |
876 m_networkState = NETWORK_LOADING; | 874 m_networkState = NETWORK_LOADING; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 | 945 |
948 #if ENABLE(WEB_AUDIO) | 946 #if ENABLE(WEB_AUDIO) |
949 if (m_audioSourceNode) | 947 if (m_audioSourceNode) |
950 m_audioSourceNode->onCurrentSrcChanged(m_currentSrc); | 948 m_audioSourceNode->onCurrentSrcChanged(m_currentSrc); |
951 #endif | 949 #endif |
952 | 950 |
953 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) - m_currentSrc -> %s", th
is, urlForLoggingMedia(m_currentSrc).utf8().data()); | 951 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) - m_currentSrc -> %s", th
is, urlForLoggingMedia(m_currentSrc).utf8().data()); |
954 | 952 |
955 startProgressEventTimer(); | 953 startProgressEventTimer(); |
956 | 954 |
957 // Reset display mode to force a recalculation of what to show because we ar
e resetting the player. | |
958 setDisplayMode(Unknown); | |
959 | |
960 setPlayerPreload(); | 955 setPlayerPreload(); |
961 | 956 |
962 if (fastHasAttribute(mutedAttr)) | 957 if (fastHasAttribute(mutedAttr)) |
963 m_muted = true; | 958 m_muted = true; |
964 updateVolume(); | 959 updateVolume(); |
965 | 960 |
966 ASSERT(!m_mediaSource); | 961 ASSERT(!m_mediaSource); |
967 | 962 |
968 bool attemptLoad = true; | 963 bool attemptLoad = true; |
969 | 964 |
(...skipping 20 matching lines...) Expand all Loading... |
990 if (!m_havePreparedToPlay && !autoplay() && preloadType() == WebMediaPla
yer::PreloadNone) { | 985 if (!m_havePreparedToPlay && !autoplay() && preloadType() == WebMediaPla
yer::PreloadNone) { |
991 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) : Delaying load b
ecause preload == 'none'", this); | 986 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) : Delaying load b
ecause preload == 'none'", this); |
992 deferLoad(); | 987 deferLoad(); |
993 } else { | 988 } else { |
994 startPlayerLoad(); | 989 startPlayerLoad(); |
995 } | 990 } |
996 } else { | 991 } else { |
997 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | 992 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
998 } | 993 } |
999 | 994 |
1000 // If there is no poster to display, allow the media engine to render video
frames as soon as | |
1001 // they are available. | |
1002 updateDisplayState(); | |
1003 | |
1004 if (layoutObject()) | 995 if (layoutObject()) |
1005 layoutObject()->updateFromElement(); | 996 layoutObject()->updateFromElement(); |
1006 } | 997 } |
1007 | 998 |
1008 void HTMLMediaElement::startPlayerLoad() | 999 void HTMLMediaElement::startPlayerLoad() |
1009 { | 1000 { |
1010 ASSERT(!m_webMediaPlayer); | 1001 ASSERT(!m_webMediaPlayer); |
1011 // Filter out user:pass as those two URL components aren't | 1002 // Filter out user:pass as those two URL components aren't |
1012 // considered for media resource fetches (including for the CORS | 1003 // considered for media resource fetches (including for the CORS |
1013 // use-credentials mode.) That behavior aligns with Gecko, with IE | 1004 // use-credentials mode.) That behavior aligns with Gecko, with IE |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1241 void HTMLMediaElement::waitForSourceChange() | 1232 void HTMLMediaElement::waitForSourceChange() |
1242 { | 1233 { |
1243 WTF_LOG(Media, "HTMLMediaElement::waitForSourceChange(%p)", this); | 1234 WTF_LOG(Media, "HTMLMediaElement::waitForSourceChange(%p)", this); |
1244 | 1235 |
1245 stopPeriodicTimers(); | 1236 stopPeriodicTimers(); |
1246 m_loadState = WaitingForSource; | 1237 m_loadState = WaitingForSource; |
1247 | 1238 |
1248 // 6.17 - Waiting: Set the element's networkState attribute to the NETWORK_N
O_SOURCE value | 1239 // 6.17 - Waiting: Set the element's networkState attribute to the NETWORK_N
O_SOURCE value |
1249 m_networkState = NETWORK_NO_SOURCE; | 1240 m_networkState = NETWORK_NO_SOURCE; |
1250 | 1241 |
1251 // 6.18 - Set the element's delaying-the-load-event flag to false. This stop
s delaying the load event. | 1242 // 6.18 - Set the element's show poster flag to true |
| 1243 setShowPoster(true); |
| 1244 |
| 1245 // 6.19 - Queue a task to set the element's delaying-the-load-event flag to
false. This stops delaying the load event. |
1252 setShouldDelayLoadEvent(false); | 1246 setShouldDelayLoadEvent(false); |
1253 | 1247 |
1254 updateDisplayState(); | |
1255 | |
1256 if (layoutObject()) | 1248 if (layoutObject()) |
1257 layoutObject()->updateFromElement(); | 1249 layoutObject()->updateFromElement(); |
1258 } | 1250 } |
1259 | 1251 |
1260 void HTMLMediaElement::noneSupported() | 1252 void HTMLMediaElement::noneSupported() |
1261 { | 1253 { |
1262 WTF_LOG(Media, "HTMLMediaElement::noneSupported(%p)", this); | 1254 WTF_LOG(Media, "HTMLMediaElement::noneSupported(%p)", this); |
1263 | 1255 |
1264 stopPeriodicTimers(); | 1256 stopPeriodicTimers(); |
1265 m_loadState = WaitingForSource; | 1257 m_loadState = WaitingForSource; |
1266 m_currentSourceNode = nullptr; | 1258 m_currentSourceNode = nullptr; |
1267 | 1259 |
1268 // 4.8.10.5 | 1260 // 4.8.13.5 |
1269 // 6 - Reaching this step indicates that the media resource failed to load o
r that the given | 1261 // 6 - Reaching this step indicates that the media resource failed to load o
r that the given |
1270 // URL could not be resolved. In one atomic operation, run the following ste
ps: | 1262 // URL could not be resolved. Queue a task to run the dedicated media sourc
e failure steps. |
1271 | 1263 |
1272 // 6.1 - Set the error attribute to a new MediaError object whose code attri
bute is set to | 1264 // 6.1 - Set the error attribute to a new MediaError object whose code attri
bute is set to |
1273 // MEDIA_ERR_SRC_NOT_SUPPORTED. | 1265 // MEDIA_ERR_SRC_NOT_SUPPORTED. |
1274 m_error = MediaError::create(MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED); | 1266 m_error = MediaError::create(MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED); |
1275 | 1267 |
1276 // 6.2 - Forget the media element's media-resource-specific text tracks. | 1268 // 6.2 - Forget the media element's media-resource-specific tracks. |
1277 forgetResourceSpecificTracks(); | 1269 forgetResourceSpecificTracks(); |
1278 | 1270 |
1279 // 6.3 - Set the element's networkState attribute to the NETWORK_NO_SOURCE v
alue. | 1271 // 6.3 - Set the element's networkState attribute to the NETWORK_NO_SOURCE v
alue. |
1280 m_networkState = NETWORK_NO_SOURCE; | 1272 m_networkState = NETWORK_NO_SOURCE; |
1281 | 1273 |
1282 // 7 - Queue a task to fire a simple event named error at the media element. | 1274 // 6.4 - Set the element's show poster flag to true. |
| 1275 setShowPoster(true); |
| 1276 |
| 1277 // 6.5 - Fire a simple event named error at the media element. |
1283 scheduleEvent(EventTypeNames::error); | 1278 scheduleEvent(EventTypeNames::error); |
1284 | 1279 |
1285 closeMediaSource(); | 1280 closeMediaSource(); |
1286 | 1281 |
1287 // 8 - Set the element's delaying-the-load-event flag to false. This stops d
elaying the load event. | 1282 // 6.6 - Set the element's delaying-the-load-event flag to false. This stops
delaying the load event. |
1288 setShouldDelayLoadEvent(false); | 1283 setShouldDelayLoadEvent(false); |
1289 | 1284 |
1290 // 9 - Abort these steps. Until the load() method is invoked or the src attr
ibute is changed, | 1285 // 7 - Wait for the task queued by the previous step to have executed. |
1291 // the element won't attempt to load another resource. | |
1292 | 1286 |
1293 updateDisplayState(); | 1287 // 8 - Abort these steps. The element won't attempt to load |
| 1288 // another resource until this algorithm is triggered again. |
1294 | 1289 |
1295 if (layoutObject()) | 1290 if (layoutObject()) |
1296 layoutObject()->updateFromElement(); | 1291 layoutObject()->updateFromElement(); |
1297 } | 1292 } |
1298 | 1293 |
1299 void HTMLMediaElement::mediaEngineError(MediaError* err) | 1294 void HTMLMediaElement::mediaEngineError(MediaError* err) |
1300 { | 1295 { |
1301 ASSERT(m_readyState >= HAVE_METADATA); | 1296 ASSERT(m_readyState >= HAVE_METADATA); |
1302 WTF_LOG(Media, "HTMLMediaElement::mediaEngineError(%p, %d)", this, static_ca
st<int>(err->code())); | 1297 WTF_LOG(Media, "HTMLMediaElement::mediaEngineError(%p, %d)", this, static_ca
st<int>(err->code())); |
1303 | 1298 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1369 | 1364 |
1370 if (error == WebMediaPlayer::NetworkStateNetworkError && m_readyState >= HAV
E_METADATA) | 1365 if (error == WebMediaPlayer::NetworkStateNetworkError && m_readyState >= HAV
E_METADATA) |
1371 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_NETWORK)); | 1366 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_NETWORK)); |
1372 else if (error == WebMediaPlayer::NetworkStateDecodeError) | 1367 else if (error == WebMediaPlayer::NetworkStateDecodeError) |
1373 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_DECODE)); | 1368 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_DECODE)); |
1374 else if ((error == WebMediaPlayer::NetworkStateFormatError | 1369 else if ((error == WebMediaPlayer::NetworkStateFormatError |
1375 || error == WebMediaPlayer::NetworkStateNetworkError) | 1370 || error == WebMediaPlayer::NetworkStateNetworkError) |
1376 && m_loadState == LoadingFromSrcAttr) | 1371 && m_loadState == LoadingFromSrcAttr) |
1377 noneSupported(); | 1372 noneSupported(); |
1378 | 1373 |
1379 updateDisplayState(); | |
1380 if (mediaControls()) | 1374 if (mediaControls()) |
1381 mediaControls()->reset(); | 1375 mediaControls()->reset(); |
1382 } | 1376 } |
1383 | 1377 |
1384 void HTMLMediaElement::setNetworkState(WebMediaPlayer::NetworkState state) | 1378 void HTMLMediaElement::setNetworkState(WebMediaPlayer::NetworkState state) |
1385 { | 1379 { |
1386 WTF_LOG(Media, "HTMLMediaElement::setNetworkState(%p, %d) - current state is
%d", this, static_cast<int>(state), static_cast<int>(m_networkState)); | 1380 WTF_LOG(Media, "HTMLMediaElement::setNetworkState(%p, %d) - current state is
%d", this, static_cast<int>(state), static_cast<int>(m_networkState)); |
1387 | 1381 |
1388 if (state == WebMediaPlayer::NetworkStateEmpty) { | 1382 if (state == WebMediaPlayer::NetworkStateEmpty) { |
1389 // Just update the cached state and leave, we can't do anything. | 1383 // Just update the cached state and leave, we can't do anything. |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1561 } | 1555 } |
1562 | 1556 |
1563 // Check for autoplay, and record metrics about it if needed. | 1557 // Check for autoplay, and record metrics about it if needed. |
1564 if (shouldAutoplay(RecordMetricsBehavior::DoRecord)) { | 1558 if (shouldAutoplay(RecordMetricsBehavior::DoRecord)) { |
1565 // If the autoplay experiment says that it's okay to play now, | 1559 // If the autoplay experiment says that it's okay to play now, |
1566 // then don't require a user gesture. | 1560 // then don't require a user gesture. |
1567 m_autoplayHelper.becameReadyToPlay(); | 1561 m_autoplayHelper.becameReadyToPlay(); |
1568 | 1562 |
1569 if (!m_userGestureRequiredForPlay) { | 1563 if (!m_userGestureRequiredForPlay) { |
1570 m_paused = false; | 1564 m_paused = false; |
| 1565 setShowPoster(false); |
1571 invalidateCachedTime(); | 1566 invalidateCachedTime(); |
1572 scheduleEvent(EventTypeNames::play); | 1567 scheduleEvent(EventTypeNames::play); |
1573 scheduleEvent(EventTypeNames::playing); | 1568 scheduleEvent(EventTypeNames::playing); |
1574 } | 1569 } |
1575 } | 1570 } |
1576 | 1571 |
1577 scheduleEvent(EventTypeNames::canplaythrough); | 1572 scheduleEvent(EventTypeNames::canplaythrough); |
1578 | 1573 |
1579 shouldUpdateDisplayState = true; | 1574 shouldUpdateDisplayState = true; |
1580 } | 1575 } |
1581 | 1576 |
1582 if (shouldUpdateDisplayState) { | 1577 if (shouldUpdateDisplayState) { |
1583 updateDisplayState(); | |
1584 if (mediaControls()) | 1578 if (mediaControls()) |
1585 mediaControls()->refreshClosedCaptionsButtonVisibility(); | 1579 mediaControls()->refreshClosedCaptionsButtonVisibility(); |
1586 } | 1580 } |
1587 | 1581 |
1588 updatePlayState(); | 1582 updatePlayState(); |
1589 updateMediaController(); | 1583 updateMediaController(); |
1590 cueTimeline().updateActiveCues(currentTime()); | 1584 cueTimeline().updateActiveCues(currentTime()); |
1591 } | 1585 } |
1592 | 1586 |
1593 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) | 1587 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1632 m_havePreparedToPlay = true; | 1626 m_havePreparedToPlay = true; |
1633 | 1627 |
1634 if (loadIsDeferred()) | 1628 if (loadIsDeferred()) |
1635 startDeferredLoad(); | 1629 startDeferredLoad(); |
1636 } | 1630 } |
1637 | 1631 |
1638 void HTMLMediaElement::seek(double time) | 1632 void HTMLMediaElement::seek(double time) |
1639 { | 1633 { |
1640 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f)", this, time); | 1634 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f)", this, time); |
1641 | 1635 |
| 1636 // 1 - Set the media element's show poster flag to false. |
| 1637 setShowPoster(false); |
1642 // 2 - If the media element's readyState is HAVE_NOTHING, abort these steps. | 1638 // 2 - If the media element's readyState is HAVE_NOTHING, abort these steps. |
1643 if (m_readyState == HAVE_NOTHING) | 1639 if (m_readyState == HAVE_NOTHING) |
1644 return; | 1640 return; |
1645 | 1641 |
1646 // If the media engine has been told to postpone loading data, let it go ahe
ad now. | 1642 // If the media engine has been told to postpone loading data, let it go ahe
ad now. |
1647 if (preloadType() < WebMediaPlayer::PreloadAuto && m_readyState < HAVE_FUTUR
E_DATA) | 1643 if (preloadType() < WebMediaPlayer::PreloadAuto && m_readyState < HAVE_FUTUR
E_DATA) |
1648 prepareToPlay(); | 1644 prepareToPlay(); |
1649 | 1645 |
1650 // Get the current time before setting m_seeking, m_lastSeekTime is returned
once it is set. | 1646 // Get the current time before setting m_seeking, m_lastSeekTime is returned
once it is set. |
1651 refreshCachedTime(); | 1647 refreshCachedTime(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1714 WTF_LOG(Media, "HTMLMediaElement::finishSeek(%p)", this); | 1710 WTF_LOG(Media, "HTMLMediaElement::finishSeek(%p)", this); |
1715 | 1711 |
1716 // 14 - Set the seeking IDL attribute to false. | 1712 // 14 - Set the seeking IDL attribute to false. |
1717 m_seeking = false; | 1713 m_seeking = false; |
1718 | 1714 |
1719 // 16 - Queue a task to fire a simple event named timeupdate at the element. | 1715 // 16 - Queue a task to fire a simple event named timeupdate at the element. |
1720 scheduleTimeupdateEvent(false); | 1716 scheduleTimeupdateEvent(false); |
1721 | 1717 |
1722 // 17 - Queue a task to fire a simple event named seeked at the element. | 1718 // 17 - Queue a task to fire a simple event named seeked at the element. |
1723 scheduleEvent(EventTypeNames::seeked); | 1719 scheduleEvent(EventTypeNames::seeked); |
1724 | |
1725 setDisplayMode(Video); | |
1726 } | 1720 } |
1727 | 1721 |
1728 HTMLMediaElement::ReadyState HTMLMediaElement::readyState() const | 1722 HTMLMediaElement::ReadyState HTMLMediaElement::readyState() const |
1729 { | 1723 { |
1730 return m_readyState; | 1724 return m_readyState; |
1731 } | 1725 } |
1732 | 1726 |
1733 bool HTMLMediaElement::hasAudio() const | 1727 bool HTMLMediaElement::hasAudio() const |
1734 { | 1728 { |
1735 return webMediaPlayer() && webMediaPlayer()->hasAudio(); | 1729 return webMediaPlayer() && webMediaPlayer()->hasAudio(); |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2003 // is ignored to seek back to start in case loop was set after playback | 1997 // is ignored to seek back to start in case loop was set after playback |
2004 // ended. See http://crbug.com/364442 | 1998 // ended. See http://crbug.com/364442 |
2005 if (endedPlayback(LoopCondition::Ignored)) | 1999 if (endedPlayback(LoopCondition::Ignored)) |
2006 seek(0); | 2000 seek(0); |
2007 | 2001 |
2008 if (m_mediaController) | 2002 if (m_mediaController) |
2009 m_mediaController->bringElementUpToSpeed(this); | 2003 m_mediaController->bringElementUpToSpeed(this); |
2010 | 2004 |
2011 if (m_paused) { | 2005 if (m_paused) { |
2012 m_paused = false; | 2006 m_paused = false; |
| 2007 setShowPoster(false); |
2013 invalidateCachedTime(); | 2008 invalidateCachedTime(); |
2014 scheduleEvent(EventTypeNames::play); | 2009 scheduleEvent(EventTypeNames::play); |
2015 | 2010 |
2016 if (m_readyState <= HAVE_CURRENT_DATA) | 2011 if (m_readyState <= HAVE_CURRENT_DATA) |
2017 scheduleEvent(EventTypeNames::waiting); | 2012 scheduleEvent(EventTypeNames::waiting); |
2018 else if (m_readyState >= HAVE_FUTURE_DATA) | 2013 else if (m_readyState >= HAVE_FUTURE_DATA) |
2019 scheduleEvent(EventTypeNames::playing); | 2014 scheduleEvent(EventTypeNames::playing); |
2020 } | 2015 } |
2021 m_autoplaying = false; | 2016 m_autoplaying = false; |
2022 | 2017 |
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2868 if (mediaControls()) | 2863 if (mediaControls()) |
2869 mediaControls()->stoppedCasting(); | 2864 mediaControls()->stoppedCasting(); |
2870 } | 2865 } |
2871 | 2866 |
2872 // MediaPlayerPresentation methods | 2867 // MediaPlayerPresentation methods |
2873 void HTMLMediaElement::repaint() | 2868 void HTMLMediaElement::repaint() |
2874 { | 2869 { |
2875 if (m_webLayer) | 2870 if (m_webLayer) |
2876 m_webLayer->invalidate(); | 2871 m_webLayer->invalidate(); |
2877 | 2872 |
2878 updateDisplayState(); | |
2879 if (layoutObject()) | 2873 if (layoutObject()) |
2880 layoutObject()->setShouldDoFullPaintInvalidation(); | 2874 layoutObject()->setShouldDoFullPaintInvalidation(); |
2881 } | 2875 } |
2882 | 2876 |
2883 void HTMLMediaElement::sizeChanged() | 2877 void HTMLMediaElement::sizeChanged() |
2884 { | 2878 { |
2885 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged(%p)", this); | 2879 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged(%p)", this); |
2886 | 2880 |
2887 ASSERT(hasVideo()); // "resize" makes no sense absent video. | 2881 ASSERT(hasVideo()); // "resize" makes no sense absent video. |
2888 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement()) | 2882 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement()) |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2981 | 2975 |
2982 void HTMLMediaElement::updatePlayState() | 2976 void HTMLMediaElement::updatePlayState() |
2983 { | 2977 { |
2984 bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused(); | 2978 bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused(); |
2985 bool shouldBePlaying = potentiallyPlaying(); | 2979 bool shouldBePlaying = potentiallyPlaying(); |
2986 | 2980 |
2987 WTF_LOG(Media, "HTMLMediaElement::updatePlayState(%p) - shouldBePlaying = %s
, isPlaying = %s", | 2981 WTF_LOG(Media, "HTMLMediaElement::updatePlayState(%p) - shouldBePlaying = %s
, isPlaying = %s", |
2988 this, boolString(shouldBePlaying), boolString(isPlaying)); | 2982 this, boolString(shouldBePlaying), boolString(isPlaying)); |
2989 | 2983 |
2990 if (shouldBePlaying) { | 2984 if (shouldBePlaying) { |
2991 setDisplayMode(Video); | |
2992 invalidateCachedTime(); | 2985 invalidateCachedTime(); |
2993 | 2986 |
2994 if (!isPlaying) { | 2987 if (!isPlaying) { |
2995 // Set rate, muted before calling play in case they were set before
the media engine was setup. | 2988 // Set rate, muted before calling play in case they were set before
the media engine was setup. |
2996 // The media engine should just stash the rate and muted values sinc
e it isn't already playing. | 2989 // The media engine should just stash the rate and muted values sinc
e it isn't already playing. |
2997 webMediaPlayer()->setRate(effectivePlaybackRate()); | 2990 webMediaPlayer()->setRate(effectivePlaybackRate()); |
2998 updateVolume(); | 2991 updateVolume(); |
2999 webMediaPlayer()->play(); | 2992 webMediaPlayer()->play(); |
3000 } | 2993 } |
3001 | 2994 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3046 | 3039 |
3047 if (m_networkState == NETWORK_EMPTY || m_completelyLoaded || m_isFinalizing) | 3040 if (m_networkState == NETWORK_EMPTY || m_completelyLoaded || m_isFinalizing) |
3048 return; | 3041 return; |
3049 | 3042 |
3050 // 2 - Set the error attribute to a new MediaError object whose code attribu
te is set to MEDIA_ERR_ABORTED. | 3043 // 2 - Set the error attribute to a new MediaError object whose code attribu
te is set to MEDIA_ERR_ABORTED. |
3051 m_error = MediaError::create(MediaError::MEDIA_ERR_ABORTED); | 3044 m_error = MediaError::create(MediaError::MEDIA_ERR_ABORTED); |
3052 | 3045 |
3053 // 3 - Queue a task to fire a simple event named error at the media element. | 3046 // 3 - Queue a task to fire a simple event named error at the media element. |
3054 scheduleEvent(EventTypeNames::abort); | 3047 scheduleEvent(EventTypeNames::abort); |
3055 | 3048 |
3056 // 4 - If the media element's readyState attribute has a value equal to HAVE
_NOTHING, set the | 3049 // 4 - If the media element's readyState attribute has a value equal to HAVE
_NOTHING, |
3057 // element's networkState attribute to the NETWORK_EMPTY value and queue a t
ask to fire a | 3050 // set the element's networkState attribute to the NETWORK_EMPTY value set t
he element's |
3058 // simple event named emptied at the element. Otherwise, set the element's n
etworkState | 3051 // show poster flag to true, and fire a simple event named emptied at the el
ement. |
3059 // attribute to the NETWORK_IDLE value. | 3052 // Otherwise, set the element's networkState attribute to the NETWORK_IDLE v
alue. |
3060 if (m_readyState == HAVE_NOTHING) { | 3053 if (m_readyState == HAVE_NOTHING) { |
3061 m_networkState = NETWORK_EMPTY; | 3054 m_networkState = NETWORK_EMPTY; |
| 3055 setShowPoster(true); |
3062 scheduleEvent(EventTypeNames::emptied); | 3056 scheduleEvent(EventTypeNames::emptied); |
3063 } else { | 3057 } else { |
3064 m_networkState = NETWORK_IDLE; | 3058 m_networkState = NETWORK_IDLE; |
3065 } | 3059 } |
3066 | 3060 |
3067 // 5 - Set the element's delaying-the-load-event flag to false. This stops d
elaying the load event. | 3061 // 5 - Set the element's delaying-the-load-event flag to false. This stops d
elaying the load event. |
3068 setShouldDelayLoadEvent(false); | 3062 setShouldDelayLoadEvent(false); |
3069 | 3063 |
3070 // 6 - Abort the overall resource selection algorithm. | 3064 // 6 - Abort the overall resource selection algorithm. |
3071 m_currentSourceNode = nullptr; | 3065 m_currentSourceNode = nullptr; |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3814 visitor->trace(m_client); | 3808 visitor->trace(m_client); |
3815 } | 3809 } |
3816 | 3810 |
3817 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) | 3811 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) |
3818 { | 3812 { |
3819 visitor->trace(m_client); | 3813 visitor->trace(m_client); |
3820 } | 3814 } |
3821 #endif | 3815 #endif |
3822 | 3816 |
3823 } | 3817 } |
OLD | NEW |