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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 , m_playbackRate(1.0f) | 239 , m_playbackRate(1.0f) |
240 , m_defaultPlaybackRate(1.0f) | 240 , m_defaultPlaybackRate(1.0f) |
241 , m_webkitPreservesPitch(true) | 241 , m_webkitPreservesPitch(true) |
242 , m_networkState(NETWORK_EMPTY) | 242 , m_networkState(NETWORK_EMPTY) |
243 , m_readyState(HAVE_NOTHING) | 243 , m_readyState(HAVE_NOTHING) |
244 , m_readyStateMaximum(HAVE_NOTHING) | 244 , m_readyStateMaximum(HAVE_NOTHING) |
245 , m_volume(1.0f) | 245 , m_volume(1.0f) |
246 , m_lastSeekTime(0) | 246 , m_lastSeekTime(0) |
247 , m_previousProgressTime(numeric_limits<double>::max()) | 247 , m_previousProgressTime(numeric_limits<double>::max()) |
248 , m_lastTimeUpdateEventWallTime(0) | 248 , m_lastTimeUpdateEventWallTime(0) |
249 , m_lastTimeUpdateEventMovieTime(numeric_limits<float>::max()) | 249 , m_lastTimeUpdateEventMovieTime(numeric_limits<double>::max()) |
250 , m_loadState(WaitingForSource) | 250 , m_loadState(WaitingForSource) |
251 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) | 251 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) |
252 , m_proxyWidget(0) | 252 , m_proxyWidget(0) |
253 #endif | 253 #endif |
254 , m_restrictions(RequireUserGestureForFullscreenRestriction | RequirePageCon
sentToLoadMediaRestriction) | 254 , m_restrictions(RequireUserGestureForFullscreenRestriction | RequirePageCon
sentToLoadMediaRestriction) |
255 , m_preload(MediaPlayer::Auto) | 255 , m_preload(MediaPlayer::Auto) |
256 , m_displayMode(Unknown) | 256 , m_displayMode(Unknown) |
257 , m_processingMediaPlayerCallback(0) | 257 , m_processingMediaPlayerCallback(0) |
258 , m_cachedTime(MediaPlayer::invalidTime()) | 258 , m_cachedTime(MediaPlayer::invalidTime()) |
259 , m_cachedTimeWallClockUpdateTime(0) | 259 , m_cachedTimeWallClockUpdateTime(0) |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 if (a.second->track() != b.second->track()) | 1023 if (a.second->track() != b.second->track()) |
1024 return trackIndexCompare(a.second->track(), b.second->track()); | 1024 return trackIndexCompare(a.second->track(), b.second->track()); |
1025 | 1025 |
1026 // 12 - Further sort tasks in events that have the same time by the | 1026 // 12 - Further sort tasks in events that have the same time by the |
1027 // relative text track cue order of the text track cues associated | 1027 // relative text track cue order of the text track cues associated |
1028 // with these tasks. | 1028 // with these tasks. |
1029 return a.second->cueIndex() - b.second->cueIndex() < 0; | 1029 return a.second->cueIndex() - b.second->cueIndex() < 0; |
1030 } | 1030 } |
1031 | 1031 |
1032 | 1032 |
1033 void HTMLMediaElement::updateActiveTextTrackCues(float movieTime) | 1033 void HTMLMediaElement::updateActiveTextTrackCues(double movieTime) |
1034 { | 1034 { |
1035 LOG(Media, "HTMLMediaElement::updateActiveTextTracks"); | 1035 LOG(Media, "HTMLMediaElement::updateActiveTextTracks"); |
1036 | 1036 |
1037 // 4.8.10.8 Playing the media resource | 1037 // 4.8.10.8 Playing the media resource |
1038 | 1038 |
1039 // If the current playback position changes while the steps are running, | 1039 // If the current playback position changes while the steps are running, |
1040 // then the user agent must wait for the steps to complete, and then must | 1040 // then the user agent must wait for the steps to complete, and then must |
1041 // immediately rerun the steps. | 1041 // immediately rerun the steps. |
1042 if (ignoreTrackDisplayUpdateRequests()) | 1042 if (ignoreTrackDisplayUpdateRequests()) |
1043 return; | 1043 return; |
(...skipping 14 matching lines...) Expand all Loading... |
1058 CueList missedCues; | 1058 CueList missedCues; |
1059 | 1059 |
1060 // 2 - Let other cues be a list of cues, initialized to contain all the cues | 1060 // 2 - Let other cues be a list of cues, initialized to contain all the cues |
1061 // of hidden, showing, and showing by default text tracks of the media | 1061 // of hidden, showing, and showing by default text tracks of the media |
1062 // element that are not present in current cues. | 1062 // element that are not present in current cues. |
1063 previousCues = m_currentlyActiveCues; | 1063 previousCues = m_currentlyActiveCues; |
1064 | 1064 |
1065 // 3 - Let last time be the current playback position at the time this | 1065 // 3 - Let last time be the current playback position at the time this |
1066 // algorithm was last run for this media element, if this is not the first | 1066 // algorithm was last run for this media element, if this is not the first |
1067 // time it has run. | 1067 // time it has run. |
1068 float lastTime = m_lastTextTrackUpdateTime; | 1068 double lastTime = m_lastTextTrackUpdateTime; |
1069 | 1069 |
1070 // 4 - If the current playback position has, since the last time this | 1070 // 4 - If the current playback position has, since the last time this |
1071 // algorithm was run, only changed through its usual monotonic increase | 1071 // algorithm was run, only changed through its usual monotonic increase |
1072 // during normal playback, then let missed cues be the list of cues in other | 1072 // during normal playback, then let missed cues be the list of cues in other |
1073 // cues whose start times are greater than or equal to last time and whose | 1073 // cues whose start times are greater than or equal to last time and whose |
1074 // end times are less than or equal to the current playback position. | 1074 // end times are less than or equal to the current playback position. |
1075 // Otherwise, let missed cues be an empty list. | 1075 // Otherwise, let missed cues be an empty list. |
1076 if (lastTime >= 0 && m_lastSeekTime < movieTime) { | 1076 if (lastTime >= 0 && m_lastSeekTime < movieTime) { |
1077 CueList potentiallySkippedCues = | 1077 CueList potentiallySkippedCues = |
1078 m_cueTree.allOverlaps(m_cueTree.createInterval(lastTime, movieTime))
; | 1078 m_cueTree.allOverlaps(m_cueTree.createInterval(lastTime, movieTime))
; |
1079 | 1079 |
1080 for (size_t i = 0; i < potentiallySkippedCues.size(); ++i) { | 1080 for (size_t i = 0; i < potentiallySkippedCues.size(); ++i) { |
1081 float cueStartTime = potentiallySkippedCues[i].low(); | 1081 double cueStartTime = potentiallySkippedCues[i].low(); |
1082 float cueEndTime = potentiallySkippedCues[i].high(); | 1082 double cueEndTime = potentiallySkippedCues[i].high(); |
1083 | 1083 |
1084 // Consider cues that may have been missed since the last seek time. | 1084 // Consider cues that may have been missed since the last seek time. |
1085 if (cueStartTime > max(m_lastSeekTime, lastTime) && cueEndTime < mov
ieTime) | 1085 if (cueStartTime > max(m_lastSeekTime, lastTime) && cueEndTime < mov
ieTime) |
1086 missedCues.append(potentiallySkippedCues[i]); | 1086 missedCues.append(potentiallySkippedCues[i]); |
1087 } | 1087 } |
1088 } | 1088 } |
1089 | 1089 |
1090 m_lastTextTrackUpdateTime = movieTime; | 1090 m_lastTextTrackUpdateTime = movieTime; |
1091 | 1091 |
1092 // 5 - If the time was reached through the usual monotonic increase of the | 1092 // 5 - If the time was reached through the usual monotonic increase of the |
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1908 renderer()->updateFromElement(); | 1908 renderer()->updateFromElement(); |
1909 if (hasMediaControls()) | 1909 if (hasMediaControls()) |
1910 mediaControls()->bufferingProgressed(); | 1910 mediaControls()->bufferingProgressed(); |
1911 } else if (timedelta > 3.0 && !m_sentStalledEvent) { | 1911 } else if (timedelta > 3.0 && !m_sentStalledEvent) { |
1912 scheduleEvent(eventNames().stalledEvent); | 1912 scheduleEvent(eventNames().stalledEvent); |
1913 m_sentStalledEvent = true; | 1913 m_sentStalledEvent = true; |
1914 setShouldDelayLoadEvent(false); | 1914 setShouldDelayLoadEvent(false); |
1915 } | 1915 } |
1916 } | 1916 } |
1917 | 1917 |
1918 void HTMLMediaElement::rewind(float timeDelta) | 1918 void HTMLMediaElement::rewind(double timeDelta) |
1919 { | 1919 { |
1920 LOG(Media, "HTMLMediaElement::rewind(%f)", timeDelta); | 1920 LOG(Media, "HTMLMediaElement::rewind(%f)", timeDelta); |
1921 setCurrentTime(max(currentTime() - timeDelta, minTimeSeekable()), IGNORE_EXC
EPTION); | 1921 setCurrentTime(max(currentTime() - timeDelta, minTimeSeekable()), IGNORE_EXC
EPTION); |
1922 } | 1922 } |
1923 | 1923 |
1924 void HTMLMediaElement::returnToRealtime() | 1924 void HTMLMediaElement::returnToRealtime() |
1925 { | 1925 { |
1926 LOG(Media, "HTMLMediaElement::returnToRealtime"); | 1926 LOG(Media, "HTMLMediaElement::returnToRealtime"); |
1927 setCurrentTime(maxTimeSeekable(), IGNORE_EXCEPTION); | 1927 setCurrentTime(maxTimeSeekable(), IGNORE_EXCEPTION); |
1928 } | 1928 } |
1929 | 1929 |
1930 void HTMLMediaElement::addPlayedRange(float start, float end) | 1930 void HTMLMediaElement::addPlayedRange(double start, double end) |
1931 { | 1931 { |
1932 LOG(Media, "HTMLMediaElement::addPlayedRange(%f, %f)", start, end); | 1932 LOG(Media, "HTMLMediaElement::addPlayedRange(%f, %f)", start, end); |
1933 if (!m_playedTimeRanges) | 1933 if (!m_playedTimeRanges) |
1934 m_playedTimeRanges = TimeRanges::create(); | 1934 m_playedTimeRanges = TimeRanges::create(); |
1935 m_playedTimeRanges->add(start, end); | 1935 m_playedTimeRanges->add(start, end); |
1936 } | 1936 } |
1937 | 1937 |
1938 bool HTMLMediaElement::supportsSave() const | 1938 bool HTMLMediaElement::supportsSave() const |
1939 { | 1939 { |
1940 return m_player ? m_player->supportsSave() : false; | 1940 return m_player ? m_player->supportsSave() : false; |
1941 } | 1941 } |
1942 | 1942 |
1943 bool HTMLMediaElement::supportsScanning() const | 1943 bool HTMLMediaElement::supportsScanning() const |
1944 { | 1944 { |
1945 return m_player ? m_player->supportsScanning() : false; | 1945 return m_player ? m_player->supportsScanning() : false; |
1946 } | 1946 } |
1947 | 1947 |
1948 void HTMLMediaElement::prepareToPlay() | 1948 void HTMLMediaElement::prepareToPlay() |
1949 { | 1949 { |
1950 LOG(Media, "HTMLMediaElement::prepareToPlay(%p)", this); | 1950 LOG(Media, "HTMLMediaElement::prepareToPlay(%p)", this); |
1951 if (m_havePreparedToPlay) | 1951 if (m_havePreparedToPlay) |
1952 return; | 1952 return; |
1953 m_havePreparedToPlay = true; | 1953 m_havePreparedToPlay = true; |
1954 m_player->prepareToPlay(); | 1954 m_player->prepareToPlay(); |
1955 } | 1955 } |
1956 | 1956 |
1957 void HTMLMediaElement::seek(float time, ExceptionCode& ec) | 1957 void HTMLMediaElement::seek(double time, ExceptionCode& ec) |
1958 { | 1958 { |
1959 LOG(Media, "HTMLMediaElement::seek(%f)", time); | 1959 LOG(Media, "HTMLMediaElement::seek(%f)", time); |
1960 | 1960 |
1961 // 4.8.9.9 Seeking | 1961 // 4.8.9.9 Seeking |
1962 | 1962 |
1963 // 1 - If the media element's readyState is HAVE_NOTHING, then raise an INVA
LID_STATE_ERR exception. | 1963 // 1 - If the media element's readyState is HAVE_NOTHING, then raise an INVA
LID_STATE_ERR exception. |
1964 if (m_readyState == HAVE_NOTHING || !m_player) { | 1964 if (m_readyState == HAVE_NOTHING || !m_player) { |
1965 ec = INVALID_STATE_ERR; | 1965 ec = INVALID_STATE_ERR; |
1966 return; | 1966 return; |
1967 } | 1967 } |
1968 | 1968 |
1969 // If the media engine has been told to postpone loading data, let it go ahe
ad now. | 1969 // If the media engine has been told to postpone loading data, let it go ahe
ad now. |
1970 if (m_preload < MediaPlayer::Auto && m_readyState < HAVE_FUTURE_DATA) | 1970 if (m_preload < MediaPlayer::Auto && m_readyState < HAVE_FUTURE_DATA) |
1971 prepareToPlay(); | 1971 prepareToPlay(); |
1972 | 1972 |
1973 // Get the current time before setting m_seeking, m_lastSeekTime is returned
once it is set. | 1973 // Get the current time before setting m_seeking, m_lastSeekTime is returned
once it is set. |
1974 refreshCachedTime(); | 1974 refreshCachedTime(); |
1975 float now = currentTime(); | 1975 double now = currentTime(); |
1976 | 1976 |
1977 // 2 - If the element's seeking IDL attribute is true, then another instance
of this algorithm is | 1977 // 2 - If the element's seeking IDL attribute is true, then another instance
of this algorithm is |
1978 // already running. Abort that other instance of the algorithm without waiti
ng for the step that | 1978 // already running. Abort that other instance of the algorithm without waiti
ng for the step that |
1979 // it is running to complete. | 1979 // it is running to complete. |
1980 // Nothing specific to be done here. | 1980 // Nothing specific to be done here. |
1981 | 1981 |
1982 // 3 - Set the seeking IDL attribute to true. | 1982 // 3 - Set the seeking IDL attribute to true. |
1983 // The flag will be cleared when the engine tells us the time has actually c
hanged. | 1983 // The flag will be cleared when the engine tells us the time has actually c
hanged. |
1984 m_seeking = true; | 1984 m_seeking = true; |
1985 | 1985 |
1986 // 5 - If the new playback position is later than the end of the media resou
rce, then let it be the end | 1986 // 5 - If the new playback position is later than the end of the media resou
rce, then let it be the end |
1987 // of the media resource instead. | 1987 // of the media resource instead. |
1988 time = min(time, duration()); | 1988 time = min(time, duration()); |
1989 | 1989 |
1990 // 6 - If the new playback position is less than the earliest possible posit
ion, let it be that position instead. | 1990 // 6 - If the new playback position is less than the earliest possible posit
ion, let it be that position instead. |
1991 float earliestTime = m_player->startTime(); | 1991 double earliestTime = m_player->startTime(); |
1992 time = max(time, earliestTime); | 1992 time = max(time, earliestTime); |
1993 | 1993 |
1994 // Ask the media engine for the time value in the movie's time scale before
comparing with current time. This | 1994 // Ask the media engine for the time value in the movie's time scale before
comparing with current time. This |
1995 // is necessary because if the seek time is not equal to currentTime but the
delta is less than the movie's | 1995 // is necessary because if the seek time is not equal to currentTime but the
delta is less than the movie's |
1996 // time scale, we will ask the media engine to "seek" to the current movie t
ime, which may be a noop and | 1996 // time scale, we will ask the media engine to "seek" to the current movie t
ime, which may be a noop and |
1997 // not generate a timechanged callback. This means m_seeking will never be c
leared and we will never | 1997 // not generate a timechanged callback. This means m_seeking will never be c
leared and we will never |
1998 // fire a 'seeked' event. | 1998 // fire a 'seeked' event. |
1999 #if !LOG_DISABLED | 1999 #if !LOG_DISABLED |
2000 float mediaTime = m_player->mediaTimeForTimeValue(time); | 2000 double mediaTime = m_player->mediaTimeForTimeValue(time); |
2001 if (time != mediaTime) | 2001 if (time != mediaTime) |
2002 LOG(Media, "HTMLMediaElement::seek(%f) - media timeline equivalent is %f
", time, mediaTime); | 2002 LOG(Media, "HTMLMediaElement::seek(%f) - media timeline equivalent is %f
", time, mediaTime); |
2003 #endif | 2003 #endif |
2004 time = m_player->mediaTimeForTimeValue(time); | 2004 time = m_player->mediaTimeForTimeValue(time); |
2005 | 2005 |
2006 // 7 - If the (possibly now changed) new playback position is not in one of
the ranges given in the | 2006 // 7 - If the (possibly now changed) new playback position is not in one of
the ranges given in the |
2007 // seekable attribute, then let it be the position in one of the ranges give
n in the seekable attribute | 2007 // seekable attribute, then let it be the position in one of the ranges give
n in the seekable attribute |
2008 // that is the nearest to the new playback position. ... If there are no ran
ges given in the seekable | 2008 // that is the nearest to the new playback position. ... If there are no ran
ges given in the seekable |
2009 // attribute then set the seeking IDL attribute to false and abort these ste
ps. | 2009 // attribute then set the seeking IDL attribute to false and abort these ste
ps. |
2010 RefPtr<TimeRanges> seekableRanges = seekable(); | 2010 RefPtr<TimeRanges> seekableRanges = seekable(); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2095 // Don't try to cache movie time when playback first starts as the time repo
rted by the engine | 2095 // Don't try to cache movie time when playback first starts as the time repo
rted by the engine |
2096 // sometimes fluctuates for a short amount of time, so the cached time will
be off if we take it | 2096 // sometimes fluctuates for a short amount of time, so the cached time will
be off if we take it |
2097 // too early. | 2097 // too early. |
2098 static const double minimumTimePlayingBeforeCacheSnapshot = 0.5; | 2098 static const double minimumTimePlayingBeforeCacheSnapshot = 0.5; |
2099 | 2099 |
2100 m_minimumWallClockTimeToCacheMediaTime = WTF::currentTime() + minimumTimePla
yingBeforeCacheSnapshot; | 2100 m_minimumWallClockTimeToCacheMediaTime = WTF::currentTime() + minimumTimePla
yingBeforeCacheSnapshot; |
2101 m_cachedTime = MediaPlayer::invalidTime(); | 2101 m_cachedTime = MediaPlayer::invalidTime(); |
2102 } | 2102 } |
2103 | 2103 |
2104 // playback state | 2104 // playback state |
2105 float HTMLMediaElement::currentTime() const | 2105 double HTMLMediaElement::currentTime() const |
2106 { | 2106 { |
2107 #if LOG_CACHED_TIME_WARNINGS | 2107 #if LOG_CACHED_TIME_WARNINGS |
2108 static const double minCachedDeltaForWarning = 0.01; | 2108 static const double minCachedDeltaForWarning = 0.01; |
2109 #endif | 2109 #endif |
2110 | 2110 |
2111 if (!m_player) | 2111 if (!m_player) |
2112 return 0; | 2112 return 0; |
2113 | 2113 |
2114 if (m_seeking) { | 2114 if (m_seeking) { |
2115 LOG(Media, "HTMLMediaElement::currentTime - seeking, returning %f", m_la
stSeekTime); | 2115 LOG(Media, "HTMLMediaElement::currentTime - seeking, returning %f", m_la
stSeekTime); |
2116 return m_lastSeekTime; | 2116 return m_lastSeekTime; |
2117 } | 2117 } |
2118 | 2118 |
2119 if (m_cachedTime != MediaPlayer::invalidTime() && m_paused) { | 2119 if (m_cachedTime != MediaPlayer::invalidTime() && m_paused) { |
2120 #if LOG_CACHED_TIME_WARNINGS | 2120 #if LOG_CACHED_TIME_WARNINGS |
2121 float delta = m_cachedTime - m_player->currentTime(); | 2121 double delta = m_cachedTime - m_player->currentTime(); |
2122 if (delta > minCachedDeltaForWarning) | 2122 if (delta > minCachedDeltaForWarning) |
2123 LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time is
%f seconds off of media time when paused", delta); | 2123 LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time is
%f seconds off of media time when paused", delta); |
2124 #endif | 2124 #endif |
2125 return m_cachedTime; | 2125 return m_cachedTime; |
2126 } | 2126 } |
2127 | 2127 |
2128 // Is it too soon use a cached time? | 2128 // Is it too soon use a cached time? |
2129 double now = WTF::currentTime(); | 2129 double now = WTF::currentTime(); |
2130 double maximumDurationToCacheMediaTime = m_player->maximumDurationToCacheMed
iaTime(); | 2130 double maximumDurationToCacheMediaTime = m_player->maximumDurationToCacheMed
iaTime(); |
2131 | 2131 |
2132 if (maximumDurationToCacheMediaTime && m_cachedTime != MediaPlayer::invalidT
ime() && !m_paused && now > m_minimumWallClockTimeToCacheMediaTime) { | 2132 if (maximumDurationToCacheMediaTime && m_cachedTime != MediaPlayer::invalidT
ime() && !m_paused && now > m_minimumWallClockTimeToCacheMediaTime) { |
2133 double wallClockDelta = now - m_cachedTimeWallClockUpdateTime; | 2133 double wallClockDelta = now - m_cachedTimeWallClockUpdateTime; |
2134 | 2134 |
2135 // Not too soon, use the cached time only if it hasn't expired. | 2135 // Not too soon, use the cached time only if it hasn't expired. |
2136 if (wallClockDelta < maximumDurationToCacheMediaTime) { | 2136 if (wallClockDelta < maximumDurationToCacheMediaTime) { |
2137 float adjustedCacheTime = static_cast<float>(m_cachedTime + (m_playb
ackRate * wallClockDelta)); | 2137 double adjustedCacheTime = m_cachedTime + (m_playbackRate * wallCloc
kDelta); |
2138 | 2138 |
2139 #if LOG_CACHED_TIME_WARNINGS | 2139 #if LOG_CACHED_TIME_WARNINGS |
2140 float delta = adjustedCacheTime - m_player->currentTime(); | 2140 double delta = adjustedCacheTime - m_player->currentTime(); |
2141 if (delta > minCachedDeltaForWarning) | 2141 if (delta > minCachedDeltaForWarning) |
2142 LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time
is %f seconds off of media time when playing", delta); | 2142 LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time
is %f seconds off of media time when playing", delta); |
2143 #endif | 2143 #endif |
2144 return adjustedCacheTime; | 2144 return adjustedCacheTime; |
2145 } | 2145 } |
2146 } | 2146 } |
2147 | 2147 |
2148 #if LOG_CACHED_TIME_WARNINGS | 2148 #if LOG_CACHED_TIME_WARNINGS |
2149 if (maximumDurationToCacheMediaTime && now > m_minimumWallClockTimeToCacheMe
diaTime && m_cachedTime != MediaPlayer::invalidTime()) { | 2149 if (maximumDurationToCacheMediaTime && now > m_minimumWallClockTimeToCacheMe
diaTime && m_cachedTime != MediaPlayer::invalidTime()) { |
2150 double wallClockDelta = now - m_cachedTimeWallClockUpdateTime; | 2150 double wallClockDelta = now - m_cachedTimeWallClockUpdateTime; |
2151 float delta = m_cachedTime + (m_playbackRate * wallClockDelta) - m_playe
r->currentTime(); | 2151 double delta = m_cachedTime + (m_playbackRate * wallClockDelta) - m_play
er->currentTime(); |
2152 LOG(Media, "HTMLMediaElement::currentTime - cached time was %f seconds o
ff of media time when it expired", delta); | 2152 LOG(Media, "HTMLMediaElement::currentTime - cached time was %f seconds o
ff of media time when it expired", delta); |
2153 } | 2153 } |
2154 #endif | 2154 #endif |
2155 | 2155 |
2156 refreshCachedTime(); | 2156 refreshCachedTime(); |
2157 | 2157 |
2158 return m_cachedTime; | 2158 return m_cachedTime; |
2159 } | 2159 } |
2160 | 2160 |
2161 void HTMLMediaElement::setCurrentTime(float time, ExceptionCode& ec) | 2161 void HTMLMediaElement::setCurrentTime(double time, ExceptionCode& ec) |
2162 { | 2162 { |
2163 if (m_mediaController) { | 2163 if (m_mediaController) { |
2164 ec = INVALID_STATE_ERR; | 2164 ec = INVALID_STATE_ERR; |
2165 return; | 2165 return; |
2166 } | 2166 } |
2167 seek(time, ec); | 2167 seek(time, ec); |
2168 } | 2168 } |
2169 | 2169 |
2170 float HTMLMediaElement::startTime() const | 2170 double HTMLMediaElement::startTime() const |
2171 { | 2171 { |
2172 if (!m_player) | 2172 if (!m_player) |
2173 return 0; | 2173 return 0; |
2174 return m_player->startTime(); | 2174 return m_player->startTime(); |
2175 } | 2175 } |
2176 | 2176 |
2177 double HTMLMediaElement::initialTime() const | 2177 double HTMLMediaElement::initialTime() const |
2178 { | 2178 { |
2179 if (m_fragmentStartTime != MediaPlayer::invalidTime()) | 2179 if (m_fragmentStartTime != MediaPlayer::invalidTime()) |
2180 return m_fragmentStartTime; | 2180 return m_fragmentStartTime; |
2181 | 2181 |
2182 if (!m_player) | 2182 if (!m_player) |
2183 return 0; | 2183 return 0; |
2184 | 2184 |
2185 return m_player->initialTime(); | 2185 return m_player->initialTime(); |
2186 } | 2186 } |
2187 | 2187 |
2188 float HTMLMediaElement::duration() const | 2188 double HTMLMediaElement::duration() const |
2189 { | 2189 { |
2190 if (m_player && m_readyState >= HAVE_METADATA) | 2190 if (m_player && m_readyState >= HAVE_METADATA) |
2191 return m_player->duration(); | 2191 return m_player->duration(); |
2192 | 2192 |
2193 return numeric_limits<float>::quiet_NaN(); | 2193 return numeric_limits<double>::quiet_NaN(); |
2194 } | 2194 } |
2195 | 2195 |
2196 bool HTMLMediaElement::paused() const | 2196 bool HTMLMediaElement::paused() const |
2197 { | 2197 { |
2198 return m_paused; | 2198 return m_paused; |
2199 } | 2199 } |
2200 | 2200 |
2201 float HTMLMediaElement::defaultPlaybackRate() const | 2201 double HTMLMediaElement::defaultPlaybackRate() const |
2202 { | 2202 { |
2203 return m_defaultPlaybackRate; | 2203 return m_defaultPlaybackRate; |
2204 } | 2204 } |
2205 | 2205 |
2206 void HTMLMediaElement::setDefaultPlaybackRate(float rate) | 2206 void HTMLMediaElement::setDefaultPlaybackRate(double rate) |
2207 { | 2207 { |
2208 if (m_defaultPlaybackRate != rate) { | 2208 if (m_defaultPlaybackRate != rate) { |
2209 m_defaultPlaybackRate = rate; | 2209 m_defaultPlaybackRate = rate; |
2210 scheduleEvent(eventNames().ratechangeEvent); | 2210 scheduleEvent(eventNames().ratechangeEvent); |
2211 } | 2211 } |
2212 } | 2212 } |
2213 | 2213 |
2214 float HTMLMediaElement::playbackRate() const | 2214 double HTMLMediaElement::playbackRate() const |
2215 { | 2215 { |
2216 return m_playbackRate; | 2216 return m_playbackRate; |
2217 } | 2217 } |
2218 | 2218 |
2219 void HTMLMediaElement::setPlaybackRate(float rate) | 2219 void HTMLMediaElement::setPlaybackRate(double rate) |
2220 { | 2220 { |
2221 LOG(Media, "HTMLMediaElement::setPlaybackRate(%f)", rate); | 2221 LOG(Media, "HTMLMediaElement::setPlaybackRate(%f)", rate); |
2222 | 2222 |
2223 if (m_playbackRate != rate) { | 2223 if (m_playbackRate != rate) { |
2224 m_playbackRate = rate; | 2224 m_playbackRate = rate; |
2225 invalidateCachedTime(); | 2225 invalidateCachedTime(); |
2226 scheduleEvent(eventNames().ratechangeEvent); | 2226 scheduleEvent(eventNames().ratechangeEvent); |
2227 } | 2227 } |
2228 | 2228 |
2229 if (m_player && potentiallyPlaying() && m_player->rate() != rate && !m_media
Controller) | 2229 if (m_player && potentiallyPlaying() && m_player->rate() != rate && !m_media
Controller) |
2230 m_player->setRate(rate); | 2230 m_player->setRate(rate); |
2231 } | 2231 } |
2232 | 2232 |
2233 void HTMLMediaElement::updatePlaybackRate() | 2233 void HTMLMediaElement::updatePlaybackRate() |
2234 { | 2234 { |
2235 float effectiveRate = m_mediaController ? m_mediaController->playbackRate()
: m_playbackRate; | 2235 double effectiveRate = m_mediaController ? m_mediaController->playbackRate()
: m_playbackRate; |
2236 if (m_player && potentiallyPlaying() && m_player->rate() != effectiveRate) | 2236 if (m_player && potentiallyPlaying() && m_player->rate() != effectiveRate) |
2237 m_player->setRate(effectiveRate); | 2237 m_player->setRate(effectiveRate); |
2238 } | 2238 } |
2239 | 2239 |
2240 bool HTMLMediaElement::webkitPreservesPitch() const | 2240 bool HTMLMediaElement::webkitPreservesPitch() const |
2241 { | 2241 { |
2242 return m_webkitPreservesPitch; | 2242 return m_webkitPreservesPitch; |
2243 } | 2243 } |
2244 | 2244 |
2245 void HTMLMediaElement::setWebkitPreservesPitch(bool preservesPitch) | 2245 void HTMLMediaElement::setWebkitPreservesPitch(bool preservesPitch) |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2519 | 2519 |
2520 return fastHasAttribute(controlsAttr); | 2520 return fastHasAttribute(controlsAttr); |
2521 } | 2521 } |
2522 | 2522 |
2523 void HTMLMediaElement::setControls(bool b) | 2523 void HTMLMediaElement::setControls(bool b) |
2524 { | 2524 { |
2525 LOG(Media, "HTMLMediaElement::setControls(%s)", boolString(b)); | 2525 LOG(Media, "HTMLMediaElement::setControls(%s)", boolString(b)); |
2526 setBooleanAttribute(controlsAttr, b); | 2526 setBooleanAttribute(controlsAttr, b); |
2527 } | 2527 } |
2528 | 2528 |
2529 float HTMLMediaElement::volume() const | 2529 double HTMLMediaElement::volume() const |
2530 { | 2530 { |
2531 return m_volume; | 2531 return m_volume; |
2532 } | 2532 } |
2533 | 2533 |
2534 void HTMLMediaElement::setVolume(float vol, ExceptionCode& ec) | 2534 void HTMLMediaElement::setVolume(double vol, ExceptionCode& ec) |
2535 { | 2535 { |
2536 LOG(Media, "HTMLMediaElement::setVolume(%f)", vol); | 2536 LOG(Media, "HTMLMediaElement::setVolume(%f)", vol); |
2537 | 2537 |
2538 if (vol < 0.0f || vol > 1.0f) { | 2538 if (vol < 0.0f || vol > 1.0f) { |
2539 ec = INDEX_SIZE_ERR; | 2539 ec = INDEX_SIZE_ERR; |
2540 return; | 2540 return; |
2541 } | 2541 } |
2542 | 2542 |
2543 if (m_volume != vol) { | 2543 if (m_volume != vol) { |
2544 m_volume = vol; | 2544 m_volume = vol; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2653 { | 2653 { |
2654 double now = WTF::currentTime(); | 2654 double now = WTF::currentTime(); |
2655 double timedelta = now - m_lastTimeUpdateEventWallTime; | 2655 double timedelta = now - m_lastTimeUpdateEventWallTime; |
2656 | 2656 |
2657 // throttle the periodic events | 2657 // throttle the periodic events |
2658 if (periodicEvent && timedelta < maxTimeupdateEventFrequency) | 2658 if (periodicEvent && timedelta < maxTimeupdateEventFrequency) |
2659 return; | 2659 return; |
2660 | 2660 |
2661 // Some media engines make multiple "time changed" callbacks at the same tim
e, but we only want one | 2661 // Some media engines make multiple "time changed" callbacks at the same tim
e, but we only want one |
2662 // event at a given time so filter here | 2662 // event at a given time so filter here |
2663 float movieTime = currentTime(); | 2663 double movieTime = currentTime(); |
2664 if (movieTime != m_lastTimeUpdateEventMovieTime) { | 2664 if (movieTime != m_lastTimeUpdateEventMovieTime) { |
2665 scheduleEvent(eventNames().timeupdateEvent); | 2665 scheduleEvent(eventNames().timeupdateEvent); |
2666 m_lastTimeUpdateEventWallTime = now; | 2666 m_lastTimeUpdateEventWallTime = now; |
2667 m_lastTimeUpdateEventMovieTime = movieTime; | 2667 m_lastTimeUpdateEventMovieTime = movieTime; |
2668 } | 2668 } |
2669 } | 2669 } |
2670 | 2670 |
2671 bool HTMLMediaElement::canPlay() const | 2671 bool HTMLMediaElement::canPlay() const |
2672 { | 2672 { |
2673 return paused() || ended() || m_readyState < HAVE_METADATA; | 2673 return paused() || ended() || m_readyState < HAVE_METADATA; |
2674 } | 2674 } |
2675 | 2675 |
2676 float HTMLMediaElement::percentLoaded() const | 2676 double HTMLMediaElement::percentLoaded() const |
2677 { | 2677 { |
2678 if (!m_player) | 2678 if (!m_player) |
2679 return 0; | 2679 return 0; |
2680 float duration = m_player->duration(); | 2680 double duration = m_player->duration(); |
2681 | 2681 |
2682 if (!duration || std::isinf(duration)) | 2682 if (!duration || std::isinf(duration)) |
2683 return 0; | 2683 return 0; |
2684 | 2684 |
2685 float buffered = 0; | 2685 double buffered = 0; |
2686 RefPtr<TimeRanges> timeRanges = m_player->buffered(); | 2686 RefPtr<TimeRanges> timeRanges = m_player->buffered(); |
2687 for (unsigned i = 0; i < timeRanges->length(); ++i) { | 2687 for (unsigned i = 0; i < timeRanges->length(); ++i) { |
2688 float start = timeRanges->start(i, IGNORE_EXCEPTION); | 2688 double start = timeRanges->start(i, IGNORE_EXCEPTION); |
2689 float end = timeRanges->end(i, IGNORE_EXCEPTION); | 2689 double end = timeRanges->end(i, IGNORE_EXCEPTION); |
2690 buffered += end - start; | 2690 buffered += end - start; |
2691 } | 2691 } |
2692 return buffered / duration; | 2692 return buffered / duration; |
2693 } | 2693 } |
2694 | 2694 |
2695 #if ENABLE(VIDEO_TRACK) | 2695 #if ENABLE(VIDEO_TRACK) |
2696 | 2696 |
2697 void HTMLMediaElement::mediaPlayerDidAddTrack(PassRefPtr<InbandTextTrackPrivate>
prpTrack) | 2697 void HTMLMediaElement::mediaPlayerDidAddTrack(PassRefPtr<InbandTextTrackPrivate>
prpTrack) |
2698 { | 2698 { |
2699 if (!RuntimeEnabledFeatures::webkitVideoTrackEnabled()) | 2699 if (!RuntimeEnabledFeatures::webkitVideoTrackEnabled()) |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3349 | 3349 |
3350 // 4.8.10.9 step 14 & 15. Needed if no ReadyState change is associated with
the seek. | 3350 // 4.8.10.9 step 14 & 15. Needed if no ReadyState change is associated with
the seek. |
3351 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !m_player->seeking()) | 3351 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !m_player->seeking()) |
3352 finishSeek(); | 3352 finishSeek(); |
3353 | 3353 |
3354 // Always call scheduleTimeupdateEvent when the media engine reports a time
discontinuity, | 3354 // Always call scheduleTimeupdateEvent when the media engine reports a time
discontinuity, |
3355 // it will only queue a 'timeupdate' event if we haven't already posted one
at the current | 3355 // it will only queue a 'timeupdate' event if we haven't already posted one
at the current |
3356 // movie time. | 3356 // movie time. |
3357 scheduleTimeupdateEvent(false); | 3357 scheduleTimeupdateEvent(false); |
3358 | 3358 |
3359 float now = currentTime(); | 3359 double now = currentTime(); |
3360 float dur = duration(); | 3360 double dur = duration(); |
3361 | 3361 |
3362 // When the current playback position reaches the end of the media resource
when the direction of | 3362 // When the current playback position reaches the end of the media resource
when the direction of |
3363 // playback is forwards, then the user agent must follow these steps: | 3363 // playback is forwards, then the user agent must follow these steps: |
3364 if (!std::isnan(dur) && dur && now >= dur && m_playbackRate > 0) { | 3364 if (!std::isnan(dur) && dur && now >= dur && m_playbackRate > 0) { |
3365 // If the media element has a loop attribute specified and does not have
a current media controller, | 3365 // If the media element has a loop attribute specified and does not have
a current media controller, |
3366 if (loop() && !m_mediaController) { | 3366 if (loop() && !m_mediaController) { |
3367 m_sentEndEvent = false; | 3367 m_sentEndEvent = false; |
3368 // then seek to the earliest possible position of the media resourc
e and abort these steps. | 3368 // then seek to the earliest possible position of the media resourc
e and abort these steps. |
3369 seek(startTime(), IGNORE_EXCEPTION); | 3369 seek(startTime(), IGNORE_EXCEPTION); |
3370 } else { | 3370 } else { |
(...skipping 21 matching lines...) Expand all Loading... |
3392 updatePlayState(); | 3392 updatePlayState(); |
3393 endProcessingMediaPlayerCallback(); | 3393 endProcessingMediaPlayerCallback(); |
3394 } | 3394 } |
3395 | 3395 |
3396 void HTMLMediaElement::mediaPlayerVolumeChanged(MediaPlayer*) | 3396 void HTMLMediaElement::mediaPlayerVolumeChanged(MediaPlayer*) |
3397 { | 3397 { |
3398 LOG(Media, "HTMLMediaElement::mediaPlayerVolumeChanged"); | 3398 LOG(Media, "HTMLMediaElement::mediaPlayerVolumeChanged"); |
3399 | 3399 |
3400 beginProcessingMediaPlayerCallback(); | 3400 beginProcessingMediaPlayerCallback(); |
3401 if (m_player) { | 3401 if (m_player) { |
3402 float vol = m_player->volume(); | 3402 double vol = m_player->volume(); |
3403 if (vol != m_volume) { | 3403 if (vol != m_volume) { |
3404 m_volume = vol; | 3404 m_volume = vol; |
3405 updateVolume(); | 3405 updateVolume(); |
3406 scheduleEvent(eventNames().volumechangeEvent); | 3406 scheduleEvent(eventNames().volumechangeEvent); |
3407 } | 3407 } |
3408 } | 3408 } |
3409 endProcessingMediaPlayerCallback(); | 3409 endProcessingMediaPlayerCallback(); |
3410 } | 3410 } |
3411 | 3411 |
3412 void HTMLMediaElement::mediaPlayerMuteChanged(MediaPlayer*) | 3412 void HTMLMediaElement::mediaPlayerMuteChanged(MediaPlayer*) |
3413 { | 3413 { |
3414 LOG(Media, "HTMLMediaElement::mediaPlayerMuteChanged"); | 3414 LOG(Media, "HTMLMediaElement::mediaPlayerMuteChanged"); |
3415 | 3415 |
3416 beginProcessingMediaPlayerCallback(); | 3416 beginProcessingMediaPlayerCallback(); |
3417 if (m_player) | 3417 if (m_player) |
3418 setMuted(m_player->muted()); | 3418 setMuted(m_player->muted()); |
3419 endProcessingMediaPlayerCallback(); | 3419 endProcessingMediaPlayerCallback(); |
3420 } | 3420 } |
3421 | 3421 |
3422 void HTMLMediaElement::mediaPlayerDurationChanged(MediaPlayer* player) | 3422 void HTMLMediaElement::mediaPlayerDurationChanged(MediaPlayer* player) |
3423 { | 3423 { |
3424 LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged"); | 3424 LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged"); |
3425 | 3425 |
3426 beginProcessingMediaPlayerCallback(); | 3426 beginProcessingMediaPlayerCallback(); |
3427 | 3427 |
3428 scheduleEvent(eventNames().durationchangeEvent); | 3428 scheduleEvent(eventNames().durationchangeEvent); |
3429 mediaPlayerCharacteristicChanged(player); | 3429 mediaPlayerCharacteristicChanged(player); |
3430 | 3430 |
3431 float now = currentTime(); | 3431 double now = currentTime(); |
3432 float dur = duration(); | 3432 double dur = duration(); |
3433 if (now > dur) | 3433 if (now > dur) |
3434 seek(dur, IGNORE_EXCEPTION); | 3434 seek(dur, IGNORE_EXCEPTION); |
3435 | 3435 |
3436 endProcessingMediaPlayerCallback(); | 3436 endProcessingMediaPlayerCallback(); |
3437 } | 3437 } |
3438 | 3438 |
3439 void HTMLMediaElement::mediaPlayerRateChanged(MediaPlayer*) | 3439 void HTMLMediaElement::mediaPlayerRateChanged(MediaPlayer*) |
3440 { | 3440 { |
3441 LOG(Media, "HTMLMediaElement::mediaPlayerRateChanged"); | 3441 LOG(Media, "HTMLMediaElement::mediaPlayerRateChanged"); |
3442 | 3442 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3577 PassRefPtr<TimeRanges> HTMLMediaElement::buffered() const | 3577 PassRefPtr<TimeRanges> HTMLMediaElement::buffered() const |
3578 { | 3578 { |
3579 if (!m_player) | 3579 if (!m_player) |
3580 return TimeRanges::create(); | 3580 return TimeRanges::create(); |
3581 return m_player->buffered(); | 3581 return m_player->buffered(); |
3582 } | 3582 } |
3583 | 3583 |
3584 PassRefPtr<TimeRanges> HTMLMediaElement::played() | 3584 PassRefPtr<TimeRanges> HTMLMediaElement::played() |
3585 { | 3585 { |
3586 if (m_playing) { | 3586 if (m_playing) { |
3587 float time = currentTime(); | 3587 double time = currentTime(); |
3588 if (time > m_lastSeekTime) | 3588 if (time > m_lastSeekTime) |
3589 addPlayedRange(m_lastSeekTime, time); | 3589 addPlayedRange(m_lastSeekTime, time); |
3590 } | 3590 } |
3591 | 3591 |
3592 if (!m_playedTimeRanges) | 3592 if (!m_playedTimeRanges) |
3593 m_playedTimeRanges = TimeRanges::create(); | 3593 m_playedTimeRanges = TimeRanges::create(); |
3594 | 3594 |
3595 return m_playedTimeRanges->copy(); | 3595 return m_playedTimeRanges->copy(); |
3596 } | 3596 } |
3597 | 3597 |
(...skipping 11 matching lines...) Expand all Loading... |
3609 return (pausedToBuffer || m_readyState >= HAVE_FUTURE_DATA) && couldPlayIfEn
oughData() && !isBlockedOnMediaController(); | 3609 return (pausedToBuffer || m_readyState >= HAVE_FUTURE_DATA) && couldPlayIfEn
oughData() && !isBlockedOnMediaController(); |
3610 } | 3610 } |
3611 | 3611 |
3612 bool HTMLMediaElement::couldPlayIfEnoughData() const | 3612 bool HTMLMediaElement::couldPlayIfEnoughData() const |
3613 { | 3613 { |
3614 return !paused() && !endedPlayback() && !stoppedDueToErrors() && !pausedForU
serInteraction(); | 3614 return !paused() && !endedPlayback() && !stoppedDueToErrors() && !pausedForU
serInteraction(); |
3615 } | 3615 } |
3616 | 3616 |
3617 bool HTMLMediaElement::endedPlayback() const | 3617 bool HTMLMediaElement::endedPlayback() const |
3618 { | 3618 { |
3619 float dur = duration(); | 3619 double dur = duration(); |
3620 if (!m_player || std::isnan(dur)) | 3620 if (!m_player || std::isnan(dur)) |
3621 return false; | 3621 return false; |
3622 | 3622 |
3623 // 4.8.10.8 Playing the media resource | 3623 // 4.8.10.8 Playing the media resource |
3624 | 3624 |
3625 // A media element is said to have ended playback when the element's | 3625 // A media element is said to have ended playback when the element's |
3626 // readyState attribute is HAVE_METADATA or greater, | 3626 // readyState attribute is HAVE_METADATA or greater, |
3627 if (m_readyState < HAVE_METADATA) | 3627 if (m_readyState < HAVE_METADATA) |
3628 return false; | 3628 return false; |
3629 | 3629 |
3630 // and the current playback position is the end of the media resource and th
e direction | 3630 // and the current playback position is the end of the media resource and th
e direction |
3631 // of playback is forwards, Either the media element does not have a loop at
tribute specified, | 3631 // of playback is forwards, Either the media element does not have a loop at
tribute specified, |
3632 // or the media element has a current media controller. | 3632 // or the media element has a current media controller. |
3633 float now = currentTime(); | 3633 double now = currentTime(); |
3634 if (m_playbackRate > 0) | 3634 if (m_playbackRate > 0) |
3635 return dur > 0 && now >= dur && (!loop() || m_mediaController); | 3635 return dur > 0 && now >= dur && (!loop() || m_mediaController); |
3636 | 3636 |
3637 // or the current playback position is the earliest possible position and th
e direction | 3637 // or the current playback position is the earliest possible position and th
e direction |
3638 // of playback is backwards | 3638 // of playback is backwards |
3639 if (m_playbackRate < 0) | 3639 if (m_playbackRate < 0) |
3640 return now <= 0; | 3640 return now <= 0; |
3641 | 3641 |
3642 return false; | 3642 return false; |
3643 } | 3643 } |
3644 | 3644 |
3645 bool HTMLMediaElement::stoppedDueToErrors() const | 3645 bool HTMLMediaElement::stoppedDueToErrors() const |
3646 { | 3646 { |
3647 if (m_readyState >= HAVE_METADATA && m_error) { | 3647 if (m_readyState >= HAVE_METADATA && m_error) { |
3648 RefPtr<TimeRanges> seekableRanges = seekable(); | 3648 RefPtr<TimeRanges> seekableRanges = seekable(); |
3649 if (!seekableRanges->contain(currentTime())) | 3649 if (!seekableRanges->contain(currentTime())) |
3650 return true; | 3650 return true; |
3651 } | 3651 } |
3652 | 3652 |
3653 return false; | 3653 return false; |
3654 } | 3654 } |
3655 | 3655 |
3656 bool HTMLMediaElement::pausedForUserInteraction() const | 3656 bool HTMLMediaElement::pausedForUserInteraction() const |
3657 { | 3657 { |
3658 // return !paused() && m_readyState >= HAVE_FUTURE_DATA && [UA requires a dec
itions from the user] | 3658 // return !paused() && m_readyState >= HAVE_FUTURE_DATA && [UA requires a dec
itions from the user] |
3659 return false; | 3659 return false; |
3660 } | 3660 } |
3661 | 3661 |
3662 float HTMLMediaElement::minTimeSeekable() const | 3662 double HTMLMediaElement::minTimeSeekable() const |
3663 { | 3663 { |
3664 return 0; | 3664 return 0; |
3665 } | 3665 } |
3666 | 3666 |
3667 float HTMLMediaElement::maxTimeSeekable() const | 3667 double HTMLMediaElement::maxTimeSeekable() const |
3668 { | 3668 { |
3669 return m_player ? m_player->maxTimeSeekable() : 0; | 3669 return m_player ? m_player->maxTimeSeekable() : 0; |
3670 } | 3670 } |
3671 | 3671 |
3672 void HTMLMediaElement::updateVolume() | 3672 void HTMLMediaElement::updateVolume() |
3673 { | 3673 { |
3674 if (!m_player) | 3674 if (!m_player) |
3675 return; | 3675 return; |
3676 | 3676 |
3677 // Avoid recursion when the player reports volume changes. | 3677 // Avoid recursion when the player reports volume changes. |
3678 if (!processingMediaPlayerCallback()) { | 3678 if (!processingMediaPlayerCallback()) { |
3679 Page* page = document()->page(); | 3679 Page* page = document()->page(); |
3680 float volumeMultiplier = page ? page->mediaVolume() : 1; | 3680 double volumeMultiplier = page ? page->mediaVolume() : 1; |
3681 bool shouldMute = m_muted; | 3681 bool shouldMute = m_muted; |
3682 | 3682 |
3683 if (m_mediaController) { | 3683 if (m_mediaController) { |
3684 volumeMultiplier *= m_mediaController->volume(); | 3684 volumeMultiplier *= m_mediaController->volume(); |
3685 shouldMute = m_mediaController->muted(); | 3685 shouldMute = m_mediaController->muted(); |
3686 } | 3686 } |
3687 | 3687 |
3688 m_player->setMuted(shouldMute); | 3688 m_player->setMuted(shouldMute); |
3689 m_player->setVolume(m_volume * volumeMultiplier); | 3689 m_player->setVolume(m_volume * volumeMultiplier); |
3690 } | 3690 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3735 startPlaybackProgressTimer(); | 3735 startPlaybackProgressTimer(); |
3736 m_playing = true; | 3736 m_playing = true; |
3737 | 3737 |
3738 } else { // Should not be playing right now | 3738 } else { // Should not be playing right now |
3739 if (!playerPaused) | 3739 if (!playerPaused) |
3740 m_player->pause(); | 3740 m_player->pause(); |
3741 refreshCachedTime(); | 3741 refreshCachedTime(); |
3742 | 3742 |
3743 m_playbackProgressTimer.stop(); | 3743 m_playbackProgressTimer.stop(); |
3744 m_playing = false; | 3744 m_playing = false; |
3745 float time = currentTime(); | 3745 double time = currentTime(); |
3746 if (time > m_lastSeekTime) | 3746 if (time > m_lastSeekTime) |
3747 addPlayedRange(m_lastSeekTime, time); | 3747 addPlayedRange(m_lastSeekTime, time); |
3748 | 3748 |
3749 if (couldPlayIfEnoughData()) | 3749 if (couldPlayIfEnoughData()) |
3750 prepareToPlay(); | 3750 prepareToPlay(); |
3751 | 3751 |
3752 if (hasMediaControls()) | 3752 if (hasMediaControls()) |
3753 mediaControls()->playbackStopped(); | 3753 mediaControls()->playbackStopped(); |
3754 } | 3754 } |
3755 | 3755 |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4569 return false; | 4569 return false; |
4570 | 4570 |
4571 // A media element is blocked on its media controller if the MediaController
is a blocked | 4571 // A media element is blocked on its media controller if the MediaController
is a blocked |
4572 // media controller, | 4572 // media controller, |
4573 if (m_mediaController->isBlocked()) | 4573 if (m_mediaController->isBlocked()) |
4574 return true; | 4574 return true; |
4575 | 4575 |
4576 // or if its media controller position is either before the media resource's
earliest possible | 4576 // or if its media controller position is either before the media resource's
earliest possible |
4577 // position relative to the MediaController's timeline or after the end of t
he media resource | 4577 // position relative to the MediaController's timeline or after the end of t
he media resource |
4578 // relative to the MediaController's timeline. | 4578 // relative to the MediaController's timeline. |
4579 float mediaControllerPosition = m_mediaController->currentTime(); | 4579 double mediaControllerPosition = m_mediaController->currentTime(); |
4580 if (mediaControllerPosition < startTime() || mediaControllerPosition > start
Time() + duration()) | 4580 if (mediaControllerPosition < startTime() || mediaControllerPosition > start
Time() + duration()) |
4581 return true; | 4581 return true; |
4582 | 4582 |
4583 return false; | 4583 return false; |
4584 } | 4584 } |
4585 | 4585 |
4586 void HTMLMediaElement::prepareMediaFragmentURI() | 4586 void HTMLMediaElement::prepareMediaFragmentURI() |
4587 { | 4587 { |
4588 MediaFragmentURIParser fragmentParser(m_currentSrc); | 4588 MediaFragmentURIParser fragmentParser(m_currentSrc); |
4589 float dur = duration(); | 4589 double dur = duration(); |
4590 | 4590 |
4591 double start = fragmentParser.startTime(); | 4591 double start = fragmentParser.startTime(); |
4592 if (start != MediaFragmentURIParser::invalidTimeValue() && start > 0) { | 4592 if (start != MediaFragmentURIParser::invalidTimeValue() && start > 0) { |
4593 m_fragmentStartTime = start; | 4593 m_fragmentStartTime = start; |
4594 if (m_fragmentStartTime > dur) | 4594 if (m_fragmentStartTime > dur) |
4595 m_fragmentStartTime = dur; | 4595 m_fragmentStartTime = dur; |
4596 } else | 4596 } else |
4597 m_fragmentStartTime = MediaPlayer::invalidTime(); | 4597 m_fragmentStartTime = MediaPlayer::invalidTime(); |
4598 | 4598 |
4599 double end = fragmentParser.endTime(); | 4599 double end = fragmentParser.endTime(); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4780 info.addMember(m_sleepDisabler, "sleepDisabler"); | 4780 info.addMember(m_sleepDisabler, "sleepDisabler"); |
4781 #endif | 4781 #endif |
4782 #if ENABLE(WEB_AUDIO) | 4782 #if ENABLE(WEB_AUDIO) |
4783 info.addMember(m_audioSourceNode, "audioSourceNode"); | 4783 info.addMember(m_audioSourceNode, "audioSourceNode"); |
4784 #endif | 4784 #endif |
4785 | 4785 |
4786 } | 4786 } |
4787 | 4787 |
4788 } | 4788 } |
4789 #endif | 4789 #endif |
OLD | NEW |