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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 , m_defaultPlaybackRate(1.0f) | 317 , m_defaultPlaybackRate(1.0f) |
318 , m_networkState(NETWORK_EMPTY) | 318 , m_networkState(NETWORK_EMPTY) |
319 , m_readyState(HAVE_NOTHING) | 319 , m_readyState(HAVE_NOTHING) |
320 , m_readyStateMaximum(HAVE_NOTHING) | 320 , m_readyStateMaximum(HAVE_NOTHING) |
321 , m_volume(1.0f) | 321 , m_volume(1.0f) |
322 , m_lastSeekTime(0) | 322 , m_lastSeekTime(0) |
323 , m_previousProgressTime(std::numeric_limits<double>::max()) | 323 , m_previousProgressTime(std::numeric_limits<double>::max()) |
324 , m_duration(std::numeric_limits<double>::quiet_NaN()) | 324 , m_duration(std::numeric_limits<double>::quiet_NaN()) |
325 , m_lastTimeUpdateEventWallTime(0) | 325 , m_lastTimeUpdateEventWallTime(0) |
326 , m_lastTimeUpdateEventMovieTime(std::numeric_limits<double>::max()) | 326 , m_lastTimeUpdateEventMovieTime(std::numeric_limits<double>::max()) |
327 , m_defaultPlaybackStartPosition(0) | |
327 , m_loadState(WaitingForSource) | 328 , m_loadState(WaitingForSource) |
328 , m_deferredLoadState(NotDeferred) | 329 , m_deferredLoadState(NotDeferred) |
329 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) | 330 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) |
330 , m_webLayer(0) | 331 , m_webLayer(0) |
331 , m_preload(MediaPlayer::Auto) | 332 , m_preload(MediaPlayer::Auto) |
332 , m_displayMode(Unknown) | 333 , m_displayMode(Unknown) |
333 , m_cachedTime(MediaPlayer::invalidTime()) | 334 , m_cachedTime(MediaPlayer::invalidTime()) |
334 , m_cachedTimeWallClockUpdateTime(0) | 335 , m_cachedTimeWallClockUpdateTime(0) |
335 , m_minimumWallClockTimeToCacheMediaTime(0) | 336 , m_minimumWallClockTimeToCacheMediaTime(0) |
336 , m_fragmentStartTime(MediaPlayer::invalidTime()) | 337 , m_fragmentStartTime(MediaPlayer::invalidTime()) |
(...skipping 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1815 prepareMediaFragmentURI(); | 1816 prepareMediaFragmentURI(); |
1816 | 1817 |
1817 selectInitialTracksIfNecessary(); | 1818 selectInitialTracksIfNecessary(); |
1818 | 1819 |
1819 m_duration = duration(); | 1820 m_duration = duration(); |
1820 scheduleEvent(EventTypeNames::durationchange); | 1821 scheduleEvent(EventTypeNames::durationchange); |
1821 | 1822 |
1822 if (isHTMLVideoElement()) | 1823 if (isHTMLVideoElement()) |
1823 scheduleEvent(EventTypeNames::resize); | 1824 scheduleEvent(EventTypeNames::resize); |
1824 scheduleEvent(EventTypeNames::loadedmetadata); | 1825 scheduleEvent(EventTypeNames::loadedmetadata); |
1826 | |
1827 if (m_defaultPlaybackStartPosition > 0) { | |
philipj_slow
2014/09/02 13:03:31
This looks like the correct place for this logic,
amogh.bihani
2014/09/02 13:39:54
Acknowledged.
| |
1828 seek(m_defaultPlaybackStartPosition, IGNORE_EXCEPTION); | |
1829 m_defaultPlaybackStartPosition = 0; | |
1830 } | |
1831 | |
1825 if (hasMediaControls()) | 1832 if (hasMediaControls()) |
1826 mediaControls()->reset(); | 1833 mediaControls()->reset(); |
1827 if (renderer()) | 1834 if (renderer()) |
1828 renderer()->updateFromElement(); | 1835 renderer()->updateFromElement(); |
1829 } | 1836 } |
1830 | 1837 |
1831 bool shouldUpdateDisplayState = false; | 1838 bool shouldUpdateDisplayState = false; |
1832 | 1839 |
1833 if (m_readyState >= HAVE_CURRENT_DATA && oldState < HAVE_CURRENT_DATA && !m_ haveFiredLoadedData) { | 1840 if (m_readyState >= HAVE_CURRENT_DATA && oldState < HAVE_CURRENT_DATA && !m_ haveFiredLoadedData) { |
1834 m_haveFiredLoadedData = true; | 1841 m_haveFiredLoadedData = true; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1921 if (loadIsDeferred()) | 1928 if (loadIsDeferred()) |
1922 startDeferredLoad(); | 1929 startDeferredLoad(); |
1923 } | 1930 } |
1924 | 1931 |
1925 void HTMLMediaElement::seek(double time, ExceptionState& exceptionState) | 1932 void HTMLMediaElement::seek(double time, ExceptionState& exceptionState) |
1926 { | 1933 { |
1927 WTF_LOG(Media, "HTMLMediaElement::seek(%f)", time); | 1934 WTF_LOG(Media, "HTMLMediaElement::seek(%f)", time); |
1928 | 1935 |
1929 // 4.8.10.9 Seeking | 1936 // 4.8.10.9 Seeking |
1930 | 1937 |
1931 // 1 - If the media element's readyState is HAVE_NOTHING, then raise an Inva lidStateError exception. | 1938 // 1 - If the media element's readyState is HAVE_NOTHING, then set the defau lt playback start |
1939 // position to that time. | |
1932 if (m_readyState == HAVE_NOTHING) { | 1940 if (m_readyState == HAVE_NOTHING) { |
1933 exceptionState.throwDOMException(InvalidStateError, "The element's ready State is HAVE_NOTHING."); | 1941 m_defaultPlaybackStartPosition = time; |
philipj_slow
2014/09/02 13:03:31
This should be moved to setCurrentTime, per "if th
amogh.bihani
2014/09/02 13:39:54
Acknowledged.
| |
1934 return; | 1942 return; |
1935 } | 1943 } |
1936 | 1944 |
1937 // If the media engine has been told to postpone loading data, let it go ahe ad now. | 1945 // If the media engine has been told to postpone loading data, let it go ahe ad now. |
1938 if (m_preload < MediaPlayer::Auto && m_readyState < HAVE_FUTURE_DATA) | 1946 if (m_preload < MediaPlayer::Auto && m_readyState < HAVE_FUTURE_DATA) |
1939 prepareToPlay(); | 1947 prepareToPlay(); |
1940 | 1948 |
1941 // Get the current time before setting m_seeking, m_lastSeekTime is returned once it is set. | 1949 // Get the current time before setting m_seeking, m_lastSeekTime is returned once it is set. |
1942 refreshCachedTime(); | 1950 refreshCachedTime(); |
1943 double now = currentTime(); | 1951 double now = currentTime(); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2068 } | 2076 } |
2069 | 2077 |
2070 // playback state | 2078 // playback state |
2071 double HTMLMediaElement::currentTime() const | 2079 double HTMLMediaElement::currentTime() const |
2072 { | 2080 { |
2073 #if LOG_CACHED_TIME_WARNINGS | 2081 #if LOG_CACHED_TIME_WARNINGS |
2074 static const double minCachedDeltaForWarning = 0.01; | 2082 static const double minCachedDeltaForWarning = 0.01; |
2075 #endif | 2083 #endif |
2076 | 2084 |
2077 if (m_readyState == HAVE_NOTHING) | 2085 if (m_readyState == HAVE_NOTHING) |
2078 return 0; | 2086 return m_defaultPlaybackStartPosition; |
philipj_slow
2014/09/02 13:03:31
The spec says "return the media element's default
amogh.bihani
2014/09/02 13:39:54
Ok, I'll do that. I thought that its value is set
| |
2079 | 2087 |
2080 if (m_seeking) { | 2088 if (m_seeking) { |
2081 WTF_LOG(Media, "HTMLMediaElement::currentTime - seeking, returning %f", m_lastSeekTime); | 2089 WTF_LOG(Media, "HTMLMediaElement::currentTime - seeking, returning %f", m_lastSeekTime); |
2082 return m_lastSeekTime; | 2090 return m_lastSeekTime; |
2083 } | 2091 } |
2084 | 2092 |
2085 if (m_cachedTime != MediaPlayer::invalidTime() && m_paused) { | 2093 if (m_cachedTime != MediaPlayer::invalidTime() && m_paused) { |
2086 #if LOG_CACHED_TIME_WARNINGS | 2094 #if LOG_CACHED_TIME_WARNINGS |
2087 double delta = m_cachedTime - webMediaPlayer()->currentTime(); | 2095 double delta = m_cachedTime - webMediaPlayer()->currentTime(); |
2088 if (delta > minCachedDeltaForWarning) | 2096 if (delta > minCachedDeltaForWarning) |
2089 WTF_LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time is %f seconds off of media time when paused", delta); | 2097 WTF_LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time is %f seconds off of media time when paused", delta); |
2090 #endif | 2098 #endif |
2091 return m_cachedTime; | 2099 return m_cachedTime; |
2092 } | 2100 } |
2093 | 2101 |
2094 refreshCachedTime(); | 2102 refreshCachedTime(); |
2095 | 2103 |
2096 return m_cachedTime; | 2104 return m_cachedTime; |
2097 } | 2105 } |
2098 | 2106 |
2099 void HTMLMediaElement::setCurrentTime(double time, ExceptionState& exceptionStat e) | 2107 void HTMLMediaElement::setCurrentTime(double time, ExceptionState& exceptionStat e) |
2100 { | 2108 { |
2101 if (m_mediaController) { | 2109 if (m_mediaController) { |
2102 exceptionState.throwDOMException(InvalidStateError, "The element is slav ed to a MediaController."); | 2110 exceptionState.throwDOMException(InvalidStateError, "The element is slav ed to a MediaController."); |
2103 return; | 2111 return; |
2104 } | 2112 } |
2113 | |
2114 if (m_networkState == NETWORK_EMPTY) { | |
2115 exceptionState.throwDOMException(InvalidStateError, "There is no media a ttached."); | |
philipj_slow
2014/09/02 13:03:31
This condition is not in the spec, why is it neede
amogh.bihani
2014/09/02 13:39:54
Oh Sorry! I got confused with this line "Test that
| |
2116 return; | |
2117 } | |
2118 | |
2105 seek(time, exceptionState); | 2119 seek(time, exceptionState); |
2106 } | 2120 } |
2107 | 2121 |
2108 double HTMLMediaElement::duration() const | 2122 double HTMLMediaElement::duration() const |
2109 { | 2123 { |
2110 // FIXME: remove m_player check once we figure out how m_player is going | 2124 // FIXME: remove m_player check once we figure out how m_player is going |
2111 // out of sync with readystate. m_player is cleared but readystate is not se t | 2125 // out of sync with readystate. m_player is cleared but readystate is not se t |
2112 // to HAVE_NOTHING | 2126 // to HAVE_NOTHING |
2113 if (!m_player || m_readyState < HAVE_METADATA) | 2127 if (!m_player || m_readyState < HAVE_METADATA) |
2114 return std::numeric_limits<double>::quiet_NaN(); | 2128 return std::numeric_limits<double>::quiet_NaN(); |
(...skipping 1874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3989 | 4003 |
3990 #if ENABLE(WEB_AUDIO) | 4004 #if ENABLE(WEB_AUDIO) |
3991 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 4005 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
3992 { | 4006 { |
3993 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) | 4007 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) |
3994 audioSourceProvider()->setClient(0); | 4008 audioSourceProvider()->setClient(0); |
3995 } | 4009 } |
3996 #endif | 4010 #endif |
3997 | 4011 |
3998 } | 4012 } |
OLD | NEW |