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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 , m_playbackRate(1.0f) | 245 , m_playbackRate(1.0f) |
246 , m_defaultPlaybackRate(1.0f) | 246 , m_defaultPlaybackRate(1.0f) |
247 , m_webkitPreservesPitch(true) | 247 , m_webkitPreservesPitch(true) |
248 , m_networkState(NETWORK_EMPTY) | 248 , m_networkState(NETWORK_EMPTY) |
249 , m_readyState(HAVE_NOTHING) | 249 , m_readyState(HAVE_NOTHING) |
250 , m_readyStateMaximum(HAVE_NOTHING) | 250 , m_readyStateMaximum(HAVE_NOTHING) |
251 , m_volume(1.0f) | 251 , m_volume(1.0f) |
252 , m_lastSeekTime(0) | 252 , m_lastSeekTime(0) |
253 , m_previousProgressTime(numeric_limits<double>::max()) | 253 , m_previousProgressTime(numeric_limits<double>::max()) |
254 , m_lastTimeUpdateEventWallTime(0) | 254 , m_lastTimeUpdateEventWallTime(0) |
255 , m_lastTimeUpdateEventMovieTime(numeric_limits<float>::max()) | 255 , m_lastTimeUpdateEventMovieTime(numeric_limits<double>::max()) |
256 , m_loadState(WaitingForSource) | 256 , m_loadState(WaitingForSource) |
257 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) | 257 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) |
258 , m_proxyWidget(0) | 258 , m_proxyWidget(0) |
259 #endif | 259 #endif |
260 , m_restrictions(RequireUserGestureForFullscreenRestriction | RequirePageCon
sentToLoadMediaRestriction) | 260 , m_restrictions(RequireUserGestureForFullscreenRestriction | RequirePageCon
sentToLoadMediaRestriction) |
261 , m_preload(MediaPlayer::Auto) | 261 , m_preload(MediaPlayer::Auto) |
262 , m_displayMode(Unknown) | 262 , m_displayMode(Unknown) |
263 , m_processingMediaPlayerCallback(0) | 263 , m_processingMediaPlayerCallback(0) |
264 , m_cachedTime(MediaPlayer::invalidTime()) | 264 , m_cachedTime(MediaPlayer::invalidTime()) |
265 , m_cachedTimeWallClockUpdateTime(0) | 265 , m_cachedTimeWallClockUpdateTime(0) |
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 if (a.second->track() != b.second->track()) | 1078 if (a.second->track() != b.second->track()) |
1079 return trackIndexCompare(a.second->track(), b.second->track()); | 1079 return trackIndexCompare(a.second->track(), b.second->track()); |
1080 | 1080 |
1081 // 12 - Further sort tasks in events that have the same time by the | 1081 // 12 - Further sort tasks in events that have the same time by the |
1082 // relative text track cue order of the text track cues associated | 1082 // relative text track cue order of the text track cues associated |
1083 // with these tasks. | 1083 // with these tasks. |
1084 return a.second->cueIndex() - b.second->cueIndex() < 0; | 1084 return a.second->cueIndex() - b.second->cueIndex() < 0; |
1085 } | 1085 } |
1086 | 1086 |
1087 | 1087 |
1088 void HTMLMediaElement::updateActiveTextTrackCues(float movieTime) | 1088 void HTMLMediaElement::updateActiveTextTrackCues(double movieTime) |
1089 { | 1089 { |
1090 LOG(Media, "HTMLMediaElement::updateActiveTextTracks"); | 1090 LOG(Media, "HTMLMediaElement::updateActiveTextTracks"); |
1091 | 1091 |
1092 // 4.8.10.8 Playing the media resource | 1092 // 4.8.10.8 Playing the media resource |
1093 | 1093 |
1094 // If the current playback position changes while the steps are running, | 1094 // If the current playback position changes while the steps are running, |
1095 // then the user agent must wait for the steps to complete, and then must | 1095 // then the user agent must wait for the steps to complete, and then must |
1096 // immediately rerun the steps. | 1096 // immediately rerun the steps. |
1097 if (ignoreTrackDisplayUpdateRequests()) | 1097 if (ignoreTrackDisplayUpdateRequests()) |
1098 return; | 1098 return; |
(...skipping 14 matching lines...) Expand all Loading... |
1113 CueList missedCues; | 1113 CueList missedCues; |
1114 | 1114 |
1115 // 2 - Let other cues be a list of cues, initialized to contain all the cues | 1115 // 2 - Let other cues be a list of cues, initialized to contain all the cues |
1116 // of hidden, showing, and showing by default text tracks of the media | 1116 // of hidden, showing, and showing by default text tracks of the media |
1117 // element that are not present in current cues. | 1117 // element that are not present in current cues. |
1118 previousCues = m_currentlyActiveCues; | 1118 previousCues = m_currentlyActiveCues; |
1119 | 1119 |
1120 // 3 - Let last time be the current playback position at the time this | 1120 // 3 - Let last time be the current playback position at the time this |
1121 // algorithm was last run for this media element, if this is not the first | 1121 // algorithm was last run for this media element, if this is not the first |
1122 // time it has run. | 1122 // time it has run. |
1123 float lastTime = m_lastTextTrackUpdateTime; | 1123 double lastTime = m_lastTextTrackUpdateTime; |
1124 | 1124 |
1125 // 4 - If the current playback position has, since the last time this | 1125 // 4 - If the current playback position has, since the last time this |
1126 // algorithm was run, only changed through its usual monotonic increase | 1126 // algorithm was run, only changed through its usual monotonic increase |
1127 // during normal playback, then let missed cues be the list of cues in other | 1127 // during normal playback, then let missed cues be the list of cues in other |
1128 // cues whose start times are greater than or equal to last time and whose | 1128 // cues whose start times are greater than or equal to last time and whose |
1129 // end times are less than or equal to the current playback position. | 1129 // end times are less than or equal to the current playback position. |
1130 // Otherwise, let missed cues be an empty list. | 1130 // Otherwise, let missed cues be an empty list. |
1131 if (lastTime >= 0 && m_lastSeekTime < movieTime) { | 1131 if (lastTime >= 0 && m_lastSeekTime < movieTime) { |
1132 CueList potentiallySkippedCues = | 1132 CueList potentiallySkippedCues = |
1133 m_cueTree.allOverlaps(m_cueTree.createInterval(lastTime, movieTime))
; | 1133 m_cueTree.allOverlaps(m_cueTree.createInterval(lastTime, movieTime))
; |
1134 | 1134 |
1135 for (size_t i = 0; i < potentiallySkippedCues.size(); ++i) { | 1135 for (size_t i = 0; i < potentiallySkippedCues.size(); ++i) { |
1136 float cueStartTime = potentiallySkippedCues[i].low(); | 1136 double cueStartTime = potentiallySkippedCues[i].low(); |
1137 float cueEndTime = potentiallySkippedCues[i].high(); | 1137 double cueEndTime = potentiallySkippedCues[i].high(); |
1138 | 1138 |
1139 // Consider cues that may have been missed since the last seek time. | 1139 // Consider cues that may have been missed since the last seek time. |
1140 if (cueStartTime > max(m_lastSeekTime, lastTime) && cueEndTime < mov
ieTime) | 1140 if (cueStartTime > max(m_lastSeekTime, lastTime) && cueEndTime < mov
ieTime) |
1141 missedCues.append(potentiallySkippedCues[i]); | 1141 missedCues.append(potentiallySkippedCues[i]); |
1142 } | 1142 } |
1143 } | 1143 } |
1144 | 1144 |
1145 m_lastTextTrackUpdateTime = movieTime; | 1145 m_lastTextTrackUpdateTime = movieTime; |
1146 | 1146 |
1147 // 5 - If the time was reached through the usual monotonic increase of the | 1147 // 5 - If the time was reached through the usual monotonic increase of the |
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1967 renderer()->updateFromElement(); | 1967 renderer()->updateFromElement(); |
1968 if (hasMediaControls()) | 1968 if (hasMediaControls()) |
1969 mediaControls()->bufferingProgressed(); | 1969 mediaControls()->bufferingProgressed(); |
1970 } else if (timedelta > 3.0 && !m_sentStalledEvent) { | 1970 } else if (timedelta > 3.0 && !m_sentStalledEvent) { |
1971 scheduleEvent(eventNames().stalledEvent); | 1971 scheduleEvent(eventNames().stalledEvent); |
1972 m_sentStalledEvent = true; | 1972 m_sentStalledEvent = true; |
1973 setShouldDelayLoadEvent(false); | 1973 setShouldDelayLoadEvent(false); |
1974 } | 1974 } |
1975 } | 1975 } |
1976 | 1976 |
1977 void HTMLMediaElement::rewind(float timeDelta) | 1977 void HTMLMediaElement::rewind(double timeDelta) |
1978 { | 1978 { |
1979 LOG(Media, "HTMLMediaElement::rewind(%f)", timeDelta); | 1979 LOG(Media, "HTMLMediaElement::rewind(%f)", timeDelta); |
1980 setCurrentTime(max(currentTime() - timeDelta, minTimeSeekable()), IGNORE_EXC
EPTION); | 1980 setCurrentTime(max(currentTime() - timeDelta, minTimeSeekable()), IGNORE_EXC
EPTION); |
1981 } | 1981 } |
1982 | 1982 |
1983 void HTMLMediaElement::returnToRealtime() | 1983 void HTMLMediaElement::returnToRealtime() |
1984 { | 1984 { |
1985 LOG(Media, "HTMLMediaElement::returnToRealtime"); | 1985 LOG(Media, "HTMLMediaElement::returnToRealtime"); |
1986 setCurrentTime(maxTimeSeekable(), IGNORE_EXCEPTION); | 1986 setCurrentTime(maxTimeSeekable(), IGNORE_EXCEPTION); |
1987 } | 1987 } |
1988 | 1988 |
1989 void HTMLMediaElement::addPlayedRange(float start, float end) | 1989 void HTMLMediaElement::addPlayedRange(double start, double end) |
1990 { | 1990 { |
1991 LOG(Media, "HTMLMediaElement::addPlayedRange(%f, %f)", start, end); | 1991 LOG(Media, "HTMLMediaElement::addPlayedRange(%f, %f)", start, end); |
1992 if (!m_playedTimeRanges) | 1992 if (!m_playedTimeRanges) |
1993 m_playedTimeRanges = TimeRanges::create(); | 1993 m_playedTimeRanges = TimeRanges::create(); |
1994 m_playedTimeRanges->add(start, end); | 1994 m_playedTimeRanges->add(start, end); |
1995 } | 1995 } |
1996 | 1996 |
1997 bool HTMLMediaElement::supportsSave() const | 1997 bool HTMLMediaElement::supportsSave() const |
1998 { | 1998 { |
1999 return m_player ? m_player->supportsSave() : false; | 1999 return m_player ? m_player->supportsSave() : false; |
2000 } | 2000 } |
2001 | 2001 |
2002 bool HTMLMediaElement::supportsScanning() const | 2002 bool HTMLMediaElement::supportsScanning() const |
2003 { | 2003 { |
2004 return m_player ? m_player->supportsScanning() : false; | 2004 return m_player ? m_player->supportsScanning() : false; |
2005 } | 2005 } |
2006 | 2006 |
2007 void HTMLMediaElement::prepareToPlay() | 2007 void HTMLMediaElement::prepareToPlay() |
2008 { | 2008 { |
2009 LOG(Media, "HTMLMediaElement::prepareToPlay(%p)", this); | 2009 LOG(Media, "HTMLMediaElement::prepareToPlay(%p)", this); |
2010 if (m_havePreparedToPlay) | 2010 if (m_havePreparedToPlay) |
2011 return; | 2011 return; |
2012 m_havePreparedToPlay = true; | 2012 m_havePreparedToPlay = true; |
2013 m_player->prepareToPlay(); | 2013 m_player->prepareToPlay(); |
2014 } | 2014 } |
2015 | 2015 |
2016 void HTMLMediaElement::seek(float time, ExceptionCode& ec) | 2016 void HTMLMediaElement::seek(double time, ExceptionCode& ec) |
2017 { | 2017 { |
2018 LOG(Media, "HTMLMediaElement::seek(%f)", time); | 2018 LOG(Media, "HTMLMediaElement::seek(%f)", time); |
2019 | 2019 |
2020 // 4.8.9.9 Seeking | 2020 // 4.8.9.9 Seeking |
2021 | 2021 |
2022 // 1 - If the media element's readyState is HAVE_NOTHING, then raise an INVA
LID_STATE_ERR exception. | 2022 // 1 - If the media element's readyState is HAVE_NOTHING, then raise an INVA
LID_STATE_ERR exception. |
2023 if (m_readyState == HAVE_NOTHING || !m_player) { | 2023 if (m_readyState == HAVE_NOTHING || !m_player) { |
2024 ec = INVALID_STATE_ERR; | 2024 ec = INVALID_STATE_ERR; |
2025 return; | 2025 return; |
2026 } | 2026 } |
2027 | 2027 |
2028 // If the media engine has been told to postpone loading data, let it go ahe
ad now. | 2028 // If the media engine has been told to postpone loading data, let it go ahe
ad now. |
2029 if (m_preload < MediaPlayer::Auto && m_readyState < HAVE_FUTURE_DATA) | 2029 if (m_preload < MediaPlayer::Auto && m_readyState < HAVE_FUTURE_DATA) |
2030 prepareToPlay(); | 2030 prepareToPlay(); |
2031 | 2031 |
2032 // Get the current time before setting m_seeking, m_lastSeekTime is returned
once it is set. | 2032 // Get the current time before setting m_seeking, m_lastSeekTime is returned
once it is set. |
2033 refreshCachedTime(); | 2033 refreshCachedTime(); |
2034 float now = currentTime(); | 2034 double now = currentTime(); |
2035 | 2035 |
2036 // 2 - If the element's seeking IDL attribute is true, then another instance
of this algorithm is | 2036 // 2 - If the element's seeking IDL attribute is true, then another instance
of this algorithm is |
2037 // already running. Abort that other instance of the algorithm without waiti
ng for the step that | 2037 // already running. Abort that other instance of the algorithm without waiti
ng for the step that |
2038 // it is running to complete. | 2038 // it is running to complete. |
2039 // Nothing specific to be done here. | 2039 // Nothing specific to be done here. |
2040 | 2040 |
2041 // 3 - Set the seeking IDL attribute to true. | 2041 // 3 - Set the seeking IDL attribute to true. |
2042 // The flag will be cleared when the engine tells us the time has actually c
hanged. | 2042 // The flag will be cleared when the engine tells us the time has actually c
hanged. |
2043 m_seeking = true; | 2043 m_seeking = true; |
2044 | 2044 |
2045 // 5 - If the new playback position is later than the end of the media resou
rce, then let it be the end | 2045 // 5 - If the new playback position is later than the end of the media resou
rce, then let it be the end |
2046 // of the media resource instead. | 2046 // of the media resource instead. |
2047 time = min(time, duration()); | 2047 time = min(time, duration()); |
2048 | 2048 |
2049 // 6 - If the new playback position is less than the earliest possible posit
ion, let it be that position instead. | 2049 // 6 - If the new playback position is less than the earliest possible posit
ion, let it be that position instead. |
2050 float earliestTime = m_player->startTime(); | 2050 double earliestTime = m_player->startTime(); |
2051 time = max(time, earliestTime); | 2051 time = max(time, earliestTime); |
2052 | 2052 |
2053 // Ask the media engine for the time value in the movie's time scale before
comparing with current time. This | 2053 // Ask the media engine for the time value in the movie's time scale before
comparing with current time. This |
2054 // is necessary because if the seek time is not equal to currentTime but the
delta is less than the movie's | 2054 // is necessary because if the seek time is not equal to currentTime but the
delta is less than the movie's |
2055 // time scale, we will ask the media engine to "seek" to the current movie t
ime, which may be a noop and | 2055 // time scale, we will ask the media engine to "seek" to the current movie t
ime, which may be a noop and |
2056 // not generate a timechanged callback. This means m_seeking will never be c
leared and we will never | 2056 // not generate a timechanged callback. This means m_seeking will never be c
leared and we will never |
2057 // fire a 'seeked' event. | 2057 // fire a 'seeked' event. |
2058 #if !LOG_DISABLED | 2058 #if !LOG_DISABLED |
2059 float mediaTime = m_player->mediaTimeForTimeValue(time); | 2059 double mediaTime = m_player->mediaTimeForTimeValue(time); |
2060 if (time != mediaTime) | 2060 if (time != mediaTime) |
2061 LOG(Media, "HTMLMediaElement::seek(%f) - media timeline equivalent is %f
", time, mediaTime); | 2061 LOG(Media, "HTMLMediaElement::seek(%f) - media timeline equivalent is %f
", time, mediaTime); |
2062 #endif | 2062 #endif |
2063 time = m_player->mediaTimeForTimeValue(time); | 2063 time = m_player->mediaTimeForTimeValue(time); |
2064 | 2064 |
2065 // 7 - If the (possibly now changed) new playback position is not in one of
the ranges given in the | 2065 // 7 - If the (possibly now changed) new playback position is not in one of
the ranges given in the |
2066 // seekable attribute, then let it be the position in one of the ranges give
n in the seekable attribute | 2066 // seekable attribute, then let it be the position in one of the ranges give
n in the seekable attribute |
2067 // that is the nearest to the new playback position. ... If there are no ran
ges given in the seekable | 2067 // that is the nearest to the new playback position. ... If there are no ran
ges given in the seekable |
2068 // attribute then set the seeking IDL attribute to false and abort these ste
ps. | 2068 // attribute then set the seeking IDL attribute to false and abort these ste
ps. |
2069 RefPtr<TimeRanges> seekableRanges = seekable(); | 2069 RefPtr<TimeRanges> seekableRanges = seekable(); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2156 // Don't try to cache movie time when playback first starts as the time repo
rted by the engine | 2156 // Don't try to cache movie time when playback first starts as the time repo
rted by the engine |
2157 // sometimes fluctuates for a short amount of time, so the cached time will
be off if we take it | 2157 // sometimes fluctuates for a short amount of time, so the cached time will
be off if we take it |
2158 // too early. | 2158 // too early. |
2159 static const double minimumTimePlayingBeforeCacheSnapshot = 0.5; | 2159 static const double minimumTimePlayingBeforeCacheSnapshot = 0.5; |
2160 | 2160 |
2161 m_minimumWallClockTimeToCacheMediaTime = WTF::currentTime() + minimumTimePla
yingBeforeCacheSnapshot; | 2161 m_minimumWallClockTimeToCacheMediaTime = WTF::currentTime() + minimumTimePla
yingBeforeCacheSnapshot; |
2162 m_cachedTime = MediaPlayer::invalidTime(); | 2162 m_cachedTime = MediaPlayer::invalidTime(); |
2163 } | 2163 } |
2164 | 2164 |
2165 // playback state | 2165 // playback state |
2166 float HTMLMediaElement::currentTime() const | 2166 double HTMLMediaElement::currentTime() const |
2167 { | 2167 { |
2168 #if LOG_CACHED_TIME_WARNINGS | 2168 #if LOG_CACHED_TIME_WARNINGS |
2169 static const double minCachedDeltaForWarning = 0.01; | 2169 static const double minCachedDeltaForWarning = 0.01; |
2170 #endif | 2170 #endif |
2171 | 2171 |
2172 if (!m_player) | 2172 if (!m_player) |
2173 return 0; | 2173 return 0; |
2174 | 2174 |
2175 if (m_seeking) { | 2175 if (m_seeking) { |
2176 LOG(Media, "HTMLMediaElement::currentTime - seeking, returning %f", m_la
stSeekTime); | 2176 LOG(Media, "HTMLMediaElement::currentTime - seeking, returning %f", m_la
stSeekTime); |
2177 return m_lastSeekTime; | 2177 return m_lastSeekTime; |
2178 } | 2178 } |
2179 | 2179 |
2180 if (m_cachedTime != MediaPlayer::invalidTime() && m_paused) { | 2180 if (m_cachedTime != MediaPlayer::invalidTime() && m_paused) { |
2181 #if LOG_CACHED_TIME_WARNINGS | 2181 #if LOG_CACHED_TIME_WARNINGS |
2182 float delta = m_cachedTime - m_player->currentTime(); | 2182 double delta = m_cachedTime - m_player->currentTime(); |
2183 if (delta > minCachedDeltaForWarning) | 2183 if (delta > minCachedDeltaForWarning) |
2184 LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time is
%f seconds off of media time when paused", delta); | 2184 LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time is
%f seconds off of media time when paused", delta); |
2185 #endif | 2185 #endif |
2186 return m_cachedTime; | 2186 return m_cachedTime; |
2187 } | 2187 } |
2188 | 2188 |
2189 // Is it too soon use a cached time? | 2189 // Is it too soon use a cached time? |
2190 double now = WTF::currentTime(); | 2190 double now = WTF::currentTime(); |
2191 double maximumDurationToCacheMediaTime = m_player->maximumDurationToCacheMed
iaTime(); | 2191 double maximumDurationToCacheMediaTime = m_player->maximumDurationToCacheMed
iaTime(); |
2192 | 2192 |
2193 if (maximumDurationToCacheMediaTime && m_cachedTime != MediaPlayer::invalidT
ime() && !m_paused && now > m_minimumWallClockTimeToCacheMediaTime) { | 2193 if (maximumDurationToCacheMediaTime && m_cachedTime != MediaPlayer::invalidT
ime() && !m_paused && now > m_minimumWallClockTimeToCacheMediaTime) { |
2194 double wallClockDelta = now - m_cachedTimeWallClockUpdateTime; | 2194 double wallClockDelta = now - m_cachedTimeWallClockUpdateTime; |
2195 | 2195 |
2196 // Not too soon, use the cached time only if it hasn't expired. | 2196 // Not too soon, use the cached time only if it hasn't expired. |
2197 if (wallClockDelta < maximumDurationToCacheMediaTime) { | 2197 if (wallClockDelta < maximumDurationToCacheMediaTime) { |
2198 float adjustedCacheTime = static_cast<float>(m_cachedTime + (m_playb
ackRate * wallClockDelta)); | 2198 double adjustedCacheTime = m_cachedTime + (m_playbackRate * wallCloc
kDelta); |
2199 | 2199 |
2200 #if LOG_CACHED_TIME_WARNINGS | 2200 #if LOG_CACHED_TIME_WARNINGS |
2201 float delta = adjustedCacheTime - m_player->currentTime(); | 2201 double delta = adjustedCacheTime - m_player->currentTime(); |
2202 if (delta > minCachedDeltaForWarning) | 2202 if (delta > minCachedDeltaForWarning) |
2203 LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time
is %f seconds off of media time when playing", delta); | 2203 LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time
is %f seconds off of media time when playing", delta); |
2204 #endif | 2204 #endif |
2205 return adjustedCacheTime; | 2205 return adjustedCacheTime; |
2206 } | 2206 } |
2207 } | 2207 } |
2208 | 2208 |
2209 #if LOG_CACHED_TIME_WARNINGS | 2209 #if LOG_CACHED_TIME_WARNINGS |
2210 if (maximumDurationToCacheMediaTime && now > m_minimumWallClockTimeToCacheMe
diaTime && m_cachedTime != MediaPlayer::invalidTime()) { | 2210 if (maximumDurationToCacheMediaTime && now > m_minimumWallClockTimeToCacheMe
diaTime && m_cachedTime != MediaPlayer::invalidTime()) { |
2211 double wallClockDelta = now - m_cachedTimeWallClockUpdateTime; | 2211 double wallClockDelta = now - m_cachedTimeWallClockUpdateTime; |
2212 float delta = m_cachedTime + (m_playbackRate * wallClockDelta) - m_playe
r->currentTime(); | 2212 double delta = m_cachedTime + (m_playbackRate * wallClockDelta) - m_play
er->currentTime(); |
2213 LOG(Media, "HTMLMediaElement::currentTime - cached time was %f seconds o
ff of media time when it expired", delta); | 2213 LOG(Media, "HTMLMediaElement::currentTime - cached time was %f seconds o
ff of media time when it expired", delta); |
2214 } | 2214 } |
2215 #endif | 2215 #endif |
2216 | 2216 |
2217 refreshCachedTime(); | 2217 refreshCachedTime(); |
2218 | 2218 |
2219 return m_cachedTime; | 2219 return m_cachedTime; |
2220 } | 2220 } |
2221 | 2221 |
2222 void HTMLMediaElement::setCurrentTime(float time, ExceptionCode& ec) | 2222 void HTMLMediaElement::setCurrentTime(double time, ExceptionCode& ec) |
2223 { | 2223 { |
2224 if (m_mediaController) { | 2224 if (m_mediaController) { |
2225 ec = INVALID_STATE_ERR; | 2225 ec = INVALID_STATE_ERR; |
2226 return; | 2226 return; |
2227 } | 2227 } |
2228 seek(time, ec); | 2228 seek(time, ec); |
2229 } | 2229 } |
2230 | 2230 |
2231 float HTMLMediaElement::startTime() const | 2231 double HTMLMediaElement::startTime() const |
2232 { | 2232 { |
2233 if (!m_player) | 2233 if (!m_player) |
2234 return 0; | 2234 return 0; |
2235 return m_player->startTime(); | 2235 return m_player->startTime(); |
2236 } | 2236 } |
2237 | 2237 |
2238 double HTMLMediaElement::initialTime() const | 2238 double HTMLMediaElement::initialTime() const |
2239 { | 2239 { |
2240 if (m_fragmentStartTime != MediaPlayer::invalidTime()) | 2240 if (m_fragmentStartTime != MediaPlayer::invalidTime()) |
2241 return m_fragmentStartTime; | 2241 return m_fragmentStartTime; |
2242 | 2242 |
2243 if (!m_player) | 2243 if (!m_player) |
2244 return 0; | 2244 return 0; |
2245 | 2245 |
2246 return m_player->initialTime(); | 2246 return m_player->initialTime(); |
2247 } | 2247 } |
2248 | 2248 |
2249 float HTMLMediaElement::duration() const | 2249 double HTMLMediaElement::duration() const |
2250 { | 2250 { |
2251 if (m_player && m_readyState >= HAVE_METADATA) | 2251 if (m_player && m_readyState >= HAVE_METADATA) |
2252 return m_player->duration(); | 2252 return m_player->duration(); |
2253 | 2253 |
2254 return numeric_limits<float>::quiet_NaN(); | 2254 return numeric_limits<double>::quiet_NaN(); |
2255 } | 2255 } |
2256 | 2256 |
2257 bool HTMLMediaElement::paused() const | 2257 bool HTMLMediaElement::paused() const |
2258 { | 2258 { |
2259 return m_paused; | 2259 return m_paused; |
2260 } | 2260 } |
2261 | 2261 |
2262 float HTMLMediaElement::defaultPlaybackRate() const | 2262 double HTMLMediaElement::defaultPlaybackRate() const |
2263 { | 2263 { |
2264 return m_defaultPlaybackRate; | 2264 return m_defaultPlaybackRate; |
2265 } | 2265 } |
2266 | 2266 |
2267 void HTMLMediaElement::setDefaultPlaybackRate(float rate) | 2267 void HTMLMediaElement::setDefaultPlaybackRate(double rate) |
2268 { | 2268 { |
2269 if (m_defaultPlaybackRate != rate) { | 2269 if (m_defaultPlaybackRate != rate) { |
2270 m_defaultPlaybackRate = rate; | 2270 m_defaultPlaybackRate = rate; |
2271 scheduleEvent(eventNames().ratechangeEvent); | 2271 scheduleEvent(eventNames().ratechangeEvent); |
2272 } | 2272 } |
2273 } | 2273 } |
2274 | 2274 |
2275 float HTMLMediaElement::playbackRate() const | 2275 double HTMLMediaElement::playbackRate() const |
2276 { | 2276 { |
2277 return m_playbackRate; | 2277 return m_playbackRate; |
2278 } | 2278 } |
2279 | 2279 |
2280 void HTMLMediaElement::setPlaybackRate(float rate) | 2280 void HTMLMediaElement::setPlaybackRate(double rate) |
2281 { | 2281 { |
2282 LOG(Media, "HTMLMediaElement::setPlaybackRate(%f)", rate); | 2282 LOG(Media, "HTMLMediaElement::setPlaybackRate(%f)", rate); |
2283 | 2283 |
2284 if (m_playbackRate != rate) { | 2284 if (m_playbackRate != rate) { |
2285 m_playbackRate = rate; | 2285 m_playbackRate = rate; |
2286 invalidateCachedTime(); | 2286 invalidateCachedTime(); |
2287 scheduleEvent(eventNames().ratechangeEvent); | 2287 scheduleEvent(eventNames().ratechangeEvent); |
2288 } | 2288 } |
2289 | 2289 |
2290 if (m_player && potentiallyPlaying() && m_player->rate() != rate && !m_media
Controller) | 2290 if (m_player && potentiallyPlaying() && m_player->rate() != rate && !m_media
Controller) |
2291 m_player->setRate(rate); | 2291 m_player->setRate(rate); |
2292 } | 2292 } |
2293 | 2293 |
2294 void HTMLMediaElement::updatePlaybackRate() | 2294 void HTMLMediaElement::updatePlaybackRate() |
2295 { | 2295 { |
2296 float effectiveRate = m_mediaController ? m_mediaController->playbackRate()
: m_playbackRate; | 2296 double effectiveRate = m_mediaController ? m_mediaController->playbackRate()
: m_playbackRate; |
2297 if (m_player && potentiallyPlaying() && m_player->rate() != effectiveRate) | 2297 if (m_player && potentiallyPlaying() && m_player->rate() != effectiveRate) |
2298 m_player->setRate(effectiveRate); | 2298 m_player->setRate(effectiveRate); |
2299 } | 2299 } |
2300 | 2300 |
2301 bool HTMLMediaElement::webkitPreservesPitch() const | 2301 bool HTMLMediaElement::webkitPreservesPitch() const |
2302 { | 2302 { |
2303 return m_webkitPreservesPitch; | 2303 return m_webkitPreservesPitch; |
2304 } | 2304 } |
2305 | 2305 |
2306 void HTMLMediaElement::setWebkitPreservesPitch(bool preservesPitch) | 2306 void HTMLMediaElement::setWebkitPreservesPitch(bool preservesPitch) |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2582 | 2582 |
2583 return fastHasAttribute(controlsAttr); | 2583 return fastHasAttribute(controlsAttr); |
2584 } | 2584 } |
2585 | 2585 |
2586 void HTMLMediaElement::setControls(bool b) | 2586 void HTMLMediaElement::setControls(bool b) |
2587 { | 2587 { |
2588 LOG(Media, "HTMLMediaElement::setControls(%s)", boolString(b)); | 2588 LOG(Media, "HTMLMediaElement::setControls(%s)", boolString(b)); |
2589 setBooleanAttribute(controlsAttr, b); | 2589 setBooleanAttribute(controlsAttr, b); |
2590 } | 2590 } |
2591 | 2591 |
2592 float HTMLMediaElement::volume() const | 2592 double HTMLMediaElement::volume() const |
2593 { | 2593 { |
2594 return m_volume; | 2594 return m_volume; |
2595 } | 2595 } |
2596 | 2596 |
2597 void HTMLMediaElement::setVolume(float vol, ExceptionCode& ec) | 2597 void HTMLMediaElement::setVolume(double vol, ExceptionCode& ec) |
2598 { | 2598 { |
2599 LOG(Media, "HTMLMediaElement::setVolume(%f)", vol); | 2599 LOG(Media, "HTMLMediaElement::setVolume(%f)", vol); |
2600 | 2600 |
2601 if (vol < 0.0f || vol > 1.0f) { | 2601 if (vol < 0.0f || vol > 1.0f) { |
2602 ec = INDEX_SIZE_ERR; | 2602 ec = INDEX_SIZE_ERR; |
2603 return; | 2603 return; |
2604 } | 2604 } |
2605 | 2605 |
2606 if (m_volume != vol) { | 2606 if (m_volume != vol) { |
2607 m_volume = vol; | 2607 m_volume = vol; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2716 { | 2716 { |
2717 double now = WTF::currentTime(); | 2717 double now = WTF::currentTime(); |
2718 double timedelta = now - m_lastTimeUpdateEventWallTime; | 2718 double timedelta = now - m_lastTimeUpdateEventWallTime; |
2719 | 2719 |
2720 // throttle the periodic events | 2720 // throttle the periodic events |
2721 if (periodicEvent && timedelta < maxTimeupdateEventFrequency) | 2721 if (periodicEvent && timedelta < maxTimeupdateEventFrequency) |
2722 return; | 2722 return; |
2723 | 2723 |
2724 // Some media engines make multiple "time changed" callbacks at the same tim
e, but we only want one | 2724 // Some media engines make multiple "time changed" callbacks at the same tim
e, but we only want one |
2725 // event at a given time so filter here | 2725 // event at a given time so filter here |
2726 float movieTime = currentTime(); | 2726 double movieTime = currentTime(); |
2727 if (movieTime != m_lastTimeUpdateEventMovieTime) { | 2727 if (movieTime != m_lastTimeUpdateEventMovieTime) { |
2728 scheduleEvent(eventNames().timeupdateEvent); | 2728 scheduleEvent(eventNames().timeupdateEvent); |
2729 m_lastTimeUpdateEventWallTime = now; | 2729 m_lastTimeUpdateEventWallTime = now; |
2730 m_lastTimeUpdateEventMovieTime = movieTime; | 2730 m_lastTimeUpdateEventMovieTime = movieTime; |
2731 } | 2731 } |
2732 } | 2732 } |
2733 | 2733 |
2734 bool HTMLMediaElement::canPlay() const | 2734 bool HTMLMediaElement::canPlay() const |
2735 { | 2735 { |
2736 return paused() || ended() || m_readyState < HAVE_METADATA; | 2736 return paused() || ended() || m_readyState < HAVE_METADATA; |
2737 } | 2737 } |
2738 | 2738 |
2739 float HTMLMediaElement::percentLoaded() const | 2739 double HTMLMediaElement::percentLoaded() const |
2740 { | 2740 { |
2741 if (!m_player) | 2741 if (!m_player) |
2742 return 0; | 2742 return 0; |
2743 float duration = m_player->duration(); | 2743 double duration = m_player->duration(); |
2744 | 2744 |
2745 if (!duration || std::isinf(duration)) | 2745 if (!duration || std::isinf(duration)) |
2746 return 0; | 2746 return 0; |
2747 | 2747 |
2748 float buffered = 0; | 2748 double buffered = 0; |
2749 RefPtr<TimeRanges> timeRanges = m_player->buffered(); | 2749 RefPtr<TimeRanges> timeRanges = m_player->buffered(); |
2750 for (unsigned i = 0; i < timeRanges->length(); ++i) { | 2750 for (unsigned i = 0; i < timeRanges->length(); ++i) { |
2751 float start = timeRanges->start(i, IGNORE_EXCEPTION); | 2751 double start = timeRanges->start(i, IGNORE_EXCEPTION); |
2752 float end = timeRanges->end(i, IGNORE_EXCEPTION); | 2752 double end = timeRanges->end(i, IGNORE_EXCEPTION); |
2753 buffered += end - start; | 2753 buffered += end - start; |
2754 } | 2754 } |
2755 return buffered / duration; | 2755 return buffered / duration; |
2756 } | 2756 } |
2757 | 2757 |
2758 #if ENABLE(VIDEO_TRACK) | 2758 #if ENABLE(VIDEO_TRACK) |
2759 | 2759 |
2760 void HTMLMediaElement::mediaPlayerDidAddTrack(PassRefPtr<InbandTextTrackPrivate>
prpTrack) | 2760 void HTMLMediaElement::mediaPlayerDidAddTrack(PassRefPtr<InbandTextTrackPrivate>
prpTrack) |
2761 { | 2761 { |
2762 if (!RuntimeEnabledFeatures::webkitVideoTrackEnabled()) | 2762 if (!RuntimeEnabledFeatures::webkitVideoTrackEnabled()) |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3412 | 3412 |
3413 // 4.8.10.9 step 14 & 15. Needed if no ReadyState change is associated with
the seek. | 3413 // 4.8.10.9 step 14 & 15. Needed if no ReadyState change is associated with
the seek. |
3414 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !m_player->seeking()) | 3414 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !m_player->seeking()) |
3415 finishSeek(); | 3415 finishSeek(); |
3416 | 3416 |
3417 // Always call scheduleTimeupdateEvent when the media engine reports a time
discontinuity, | 3417 // Always call scheduleTimeupdateEvent when the media engine reports a time
discontinuity, |
3418 // it will only queue a 'timeupdate' event if we haven't already posted one
at the current | 3418 // it will only queue a 'timeupdate' event if we haven't already posted one
at the current |
3419 // movie time. | 3419 // movie time. |
3420 scheduleTimeupdateEvent(false); | 3420 scheduleTimeupdateEvent(false); |
3421 | 3421 |
3422 float now = currentTime(); | 3422 double now = currentTime(); |
3423 float dur = duration(); | 3423 double dur = duration(); |
3424 | 3424 |
3425 // When the current playback position reaches the end of the media resource
when the direction of | 3425 // When the current playback position reaches the end of the media resource
when the direction of |
3426 // playback is forwards, then the user agent must follow these steps: | 3426 // playback is forwards, then the user agent must follow these steps: |
3427 if (!std::isnan(dur) && dur && now >= dur && m_playbackRate > 0) { | 3427 if (!std::isnan(dur) && dur && now >= dur && m_playbackRate > 0) { |
3428 // If the media element has a loop attribute specified and does not have
a current media controller, | 3428 // If the media element has a loop attribute specified and does not have
a current media controller, |
3429 if (loop() && !m_mediaController) { | 3429 if (loop() && !m_mediaController) { |
3430 m_sentEndEvent = false; | 3430 m_sentEndEvent = false; |
3431 // then seek to the earliest possible position of the media resourc
e and abort these steps. | 3431 // then seek to the earliest possible position of the media resourc
e and abort these steps. |
3432 seek(startTime(), IGNORE_EXCEPTION); | 3432 seek(startTime(), IGNORE_EXCEPTION); |
3433 } else { | 3433 } else { |
(...skipping 21 matching lines...) Expand all Loading... |
3455 updatePlayState(); | 3455 updatePlayState(); |
3456 endProcessingMediaPlayerCallback(); | 3456 endProcessingMediaPlayerCallback(); |
3457 } | 3457 } |
3458 | 3458 |
3459 void HTMLMediaElement::mediaPlayerVolumeChanged(MediaPlayer*) | 3459 void HTMLMediaElement::mediaPlayerVolumeChanged(MediaPlayer*) |
3460 { | 3460 { |
3461 LOG(Media, "HTMLMediaElement::mediaPlayerVolumeChanged"); | 3461 LOG(Media, "HTMLMediaElement::mediaPlayerVolumeChanged"); |
3462 | 3462 |
3463 beginProcessingMediaPlayerCallback(); | 3463 beginProcessingMediaPlayerCallback(); |
3464 if (m_player) { | 3464 if (m_player) { |
3465 float vol = m_player->volume(); | 3465 double vol = m_player->volume(); |
3466 if (vol != m_volume) { | 3466 if (vol != m_volume) { |
3467 m_volume = vol; | 3467 m_volume = vol; |
3468 updateVolume(); | 3468 updateVolume(); |
3469 scheduleEvent(eventNames().volumechangeEvent); | 3469 scheduleEvent(eventNames().volumechangeEvent); |
3470 } | 3470 } |
3471 } | 3471 } |
3472 endProcessingMediaPlayerCallback(); | 3472 endProcessingMediaPlayerCallback(); |
3473 } | 3473 } |
3474 | 3474 |
3475 void HTMLMediaElement::mediaPlayerMuteChanged(MediaPlayer*) | 3475 void HTMLMediaElement::mediaPlayerMuteChanged(MediaPlayer*) |
3476 { | 3476 { |
3477 LOG(Media, "HTMLMediaElement::mediaPlayerMuteChanged"); | 3477 LOG(Media, "HTMLMediaElement::mediaPlayerMuteChanged"); |
3478 | 3478 |
3479 beginProcessingMediaPlayerCallback(); | 3479 beginProcessingMediaPlayerCallback(); |
3480 if (m_player) | 3480 if (m_player) |
3481 setMuted(m_player->muted()); | 3481 setMuted(m_player->muted()); |
3482 endProcessingMediaPlayerCallback(); | 3482 endProcessingMediaPlayerCallback(); |
3483 } | 3483 } |
3484 | 3484 |
3485 void HTMLMediaElement::mediaPlayerDurationChanged(MediaPlayer* player) | 3485 void HTMLMediaElement::mediaPlayerDurationChanged(MediaPlayer* player) |
3486 { | 3486 { |
3487 LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged"); | 3487 LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged"); |
3488 | 3488 |
3489 beginProcessingMediaPlayerCallback(); | 3489 beginProcessingMediaPlayerCallback(); |
3490 | 3490 |
3491 scheduleEvent(eventNames().durationchangeEvent); | 3491 scheduleEvent(eventNames().durationchangeEvent); |
3492 mediaPlayerCharacteristicChanged(player); | 3492 mediaPlayerCharacteristicChanged(player); |
3493 | 3493 |
3494 float now = currentTime(); | 3494 double now = currentTime(); |
3495 float dur = duration(); | 3495 double dur = duration(); |
3496 if (now > dur) | 3496 if (now > dur) |
3497 seek(dur, IGNORE_EXCEPTION); | 3497 seek(dur, IGNORE_EXCEPTION); |
3498 | 3498 |
3499 endProcessingMediaPlayerCallback(); | 3499 endProcessingMediaPlayerCallback(); |
3500 } | 3500 } |
3501 | 3501 |
3502 void HTMLMediaElement::mediaPlayerRateChanged(MediaPlayer*) | 3502 void HTMLMediaElement::mediaPlayerRateChanged(MediaPlayer*) |
3503 { | 3503 { |
3504 LOG(Media, "HTMLMediaElement::mediaPlayerRateChanged"); | 3504 LOG(Media, "HTMLMediaElement::mediaPlayerRateChanged"); |
3505 | 3505 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3640 PassRefPtr<TimeRanges> HTMLMediaElement::buffered() const | 3640 PassRefPtr<TimeRanges> HTMLMediaElement::buffered() const |
3641 { | 3641 { |
3642 if (!m_player) | 3642 if (!m_player) |
3643 return TimeRanges::create(); | 3643 return TimeRanges::create(); |
3644 return m_player->buffered(); | 3644 return m_player->buffered(); |
3645 } | 3645 } |
3646 | 3646 |
3647 PassRefPtr<TimeRanges> HTMLMediaElement::played() | 3647 PassRefPtr<TimeRanges> HTMLMediaElement::played() |
3648 { | 3648 { |
3649 if (m_playing) { | 3649 if (m_playing) { |
3650 float time = currentTime(); | 3650 double time = currentTime(); |
3651 if (time > m_lastSeekTime) | 3651 if (time > m_lastSeekTime) |
3652 addPlayedRange(m_lastSeekTime, time); | 3652 addPlayedRange(m_lastSeekTime, time); |
3653 } | 3653 } |
3654 | 3654 |
3655 if (!m_playedTimeRanges) | 3655 if (!m_playedTimeRanges) |
3656 m_playedTimeRanges = TimeRanges::create(); | 3656 m_playedTimeRanges = TimeRanges::create(); |
3657 | 3657 |
3658 return m_playedTimeRanges->copy(); | 3658 return m_playedTimeRanges->copy(); |
3659 } | 3659 } |
3660 | 3660 |
(...skipping 11 matching lines...) Expand all Loading... |
3672 return (pausedToBuffer || m_readyState >= HAVE_FUTURE_DATA) && couldPlayIfEn
oughData() && !isBlockedOnMediaController(); | 3672 return (pausedToBuffer || m_readyState >= HAVE_FUTURE_DATA) && couldPlayIfEn
oughData() && !isBlockedOnMediaController(); |
3673 } | 3673 } |
3674 | 3674 |
3675 bool HTMLMediaElement::couldPlayIfEnoughData() const | 3675 bool HTMLMediaElement::couldPlayIfEnoughData() const |
3676 { | 3676 { |
3677 return !paused() && !endedPlayback() && !stoppedDueToErrors() && !pausedForU
serInteraction(); | 3677 return !paused() && !endedPlayback() && !stoppedDueToErrors() && !pausedForU
serInteraction(); |
3678 } | 3678 } |
3679 | 3679 |
3680 bool HTMLMediaElement::endedPlayback() const | 3680 bool HTMLMediaElement::endedPlayback() const |
3681 { | 3681 { |
3682 float dur = duration(); | 3682 double dur = duration(); |
3683 if (!m_player || std::isnan(dur)) | 3683 if (!m_player || std::isnan(dur)) |
3684 return false; | 3684 return false; |
3685 | 3685 |
3686 // 4.8.10.8 Playing the media resource | 3686 // 4.8.10.8 Playing the media resource |
3687 | 3687 |
3688 // A media element is said to have ended playback when the element's | 3688 // A media element is said to have ended playback when the element's |
3689 // readyState attribute is HAVE_METADATA or greater, | 3689 // readyState attribute is HAVE_METADATA or greater, |
3690 if (m_readyState < HAVE_METADATA) | 3690 if (m_readyState < HAVE_METADATA) |
3691 return false; | 3691 return false; |
3692 | 3692 |
3693 // and the current playback position is the end of the media resource and th
e direction | 3693 // and the current playback position is the end of the media resource and th
e direction |
3694 // of playback is forwards, Either the media element does not have a loop at
tribute specified, | 3694 // of playback is forwards, Either the media element does not have a loop at
tribute specified, |
3695 // or the media element has a current media controller. | 3695 // or the media element has a current media controller. |
3696 float now = currentTime(); | 3696 double now = currentTime(); |
3697 if (m_playbackRate > 0) | 3697 if (m_playbackRate > 0) |
3698 return dur > 0 && now >= dur && (!loop() || m_mediaController); | 3698 return dur > 0 && now >= dur && (!loop() || m_mediaController); |
3699 | 3699 |
3700 // or the current playback position is the earliest possible position and th
e direction | 3700 // or the current playback position is the earliest possible position and th
e direction |
3701 // of playback is backwards | 3701 // of playback is backwards |
3702 if (m_playbackRate < 0) | 3702 if (m_playbackRate < 0) |
3703 return now <= 0; | 3703 return now <= 0; |
3704 | 3704 |
3705 return false; | 3705 return false; |
3706 } | 3706 } |
3707 | 3707 |
3708 bool HTMLMediaElement::stoppedDueToErrors() const | 3708 bool HTMLMediaElement::stoppedDueToErrors() const |
3709 { | 3709 { |
3710 if (m_readyState >= HAVE_METADATA && m_error) { | 3710 if (m_readyState >= HAVE_METADATA && m_error) { |
3711 RefPtr<TimeRanges> seekableRanges = seekable(); | 3711 RefPtr<TimeRanges> seekableRanges = seekable(); |
3712 if (!seekableRanges->contain(currentTime())) | 3712 if (!seekableRanges->contain(currentTime())) |
3713 return true; | 3713 return true; |
3714 } | 3714 } |
3715 | 3715 |
3716 return false; | 3716 return false; |
3717 } | 3717 } |
3718 | 3718 |
3719 bool HTMLMediaElement::pausedForUserInteraction() const | 3719 bool HTMLMediaElement::pausedForUserInteraction() const |
3720 { | 3720 { |
3721 // return !paused() && m_readyState >= HAVE_FUTURE_DATA && [UA requires a dec
itions from the user] | 3721 // return !paused() && m_readyState >= HAVE_FUTURE_DATA && [UA requires a dec
itions from the user] |
3722 return false; | 3722 return false; |
3723 } | 3723 } |
3724 | 3724 |
3725 float HTMLMediaElement::minTimeSeekable() const | 3725 double HTMLMediaElement::minTimeSeekable() const |
3726 { | 3726 { |
3727 return 0; | 3727 return 0; |
3728 } | 3728 } |
3729 | 3729 |
3730 float HTMLMediaElement::maxTimeSeekable() const | 3730 double HTMLMediaElement::maxTimeSeekable() const |
3731 { | 3731 { |
3732 return m_player ? m_player->maxTimeSeekable() : 0; | 3732 return m_player ? m_player->maxTimeSeekable() : 0; |
3733 } | 3733 } |
3734 | 3734 |
3735 void HTMLMediaElement::updateVolume() | 3735 void HTMLMediaElement::updateVolume() |
3736 { | 3736 { |
3737 if (!m_player) | 3737 if (!m_player) |
3738 return; | 3738 return; |
3739 | 3739 |
3740 // Avoid recursion when the player reports volume changes. | 3740 // Avoid recursion when the player reports volume changes. |
3741 if (!processingMediaPlayerCallback()) { | 3741 if (!processingMediaPlayerCallback()) { |
3742 Page* page = document()->page(); | 3742 Page* page = document()->page(); |
3743 float volumeMultiplier = page ? page->mediaVolume() : 1; | 3743 double volumeMultiplier = page ? page->mediaVolume() : 1; |
3744 bool shouldMute = m_muted; | 3744 bool shouldMute = m_muted; |
3745 | 3745 |
3746 if (m_mediaController) { | 3746 if (m_mediaController) { |
3747 volumeMultiplier *= m_mediaController->volume(); | 3747 volumeMultiplier *= m_mediaController->volume(); |
3748 shouldMute = m_mediaController->muted(); | 3748 shouldMute = m_mediaController->muted(); |
3749 } | 3749 } |
3750 | 3750 |
3751 m_player->setMuted(shouldMute); | 3751 m_player->setMuted(shouldMute); |
3752 m_player->setVolume(m_volume * volumeMultiplier); | 3752 m_player->setVolume(m_volume * volumeMultiplier); |
3753 } | 3753 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3798 startPlaybackProgressTimer(); | 3798 startPlaybackProgressTimer(); |
3799 m_playing = true; | 3799 m_playing = true; |
3800 | 3800 |
3801 } else { // Should not be playing right now | 3801 } else { // Should not be playing right now |
3802 if (!playerPaused) | 3802 if (!playerPaused) |
3803 m_player->pause(); | 3803 m_player->pause(); |
3804 refreshCachedTime(); | 3804 refreshCachedTime(); |
3805 | 3805 |
3806 m_playbackProgressTimer.stop(); | 3806 m_playbackProgressTimer.stop(); |
3807 m_playing = false; | 3807 m_playing = false; |
3808 float time = currentTime(); | 3808 double time = currentTime(); |
3809 if (time > m_lastSeekTime) | 3809 if (time > m_lastSeekTime) |
3810 addPlayedRange(m_lastSeekTime, time); | 3810 addPlayedRange(m_lastSeekTime, time); |
3811 | 3811 |
3812 if (couldPlayIfEnoughData()) | 3812 if (couldPlayIfEnoughData()) |
3813 prepareToPlay(); | 3813 prepareToPlay(); |
3814 | 3814 |
3815 if (hasMediaControls()) | 3815 if (hasMediaControls()) |
3816 mediaControls()->playbackStopped(); | 3816 mediaControls()->playbackStopped(); |
3817 } | 3817 } |
3818 | 3818 |
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4638 return false; | 4638 return false; |
4639 | 4639 |
4640 // A media element is blocked on its media controller if the MediaController
is a blocked | 4640 // A media element is blocked on its media controller if the MediaController
is a blocked |
4641 // media controller, | 4641 // media controller, |
4642 if (m_mediaController->isBlocked()) | 4642 if (m_mediaController->isBlocked()) |
4643 return true; | 4643 return true; |
4644 | 4644 |
4645 // or if its media controller position is either before the media resource's
earliest possible | 4645 // or if its media controller position is either before the media resource's
earliest possible |
4646 // position relative to the MediaController's timeline or after the end of t
he media resource | 4646 // position relative to the MediaController's timeline or after the end of t
he media resource |
4647 // relative to the MediaController's timeline. | 4647 // relative to the MediaController's timeline. |
4648 float mediaControllerPosition = m_mediaController->currentTime(); | 4648 double mediaControllerPosition = m_mediaController->currentTime(); |
4649 if (mediaControllerPosition < startTime() || mediaControllerPosition > start
Time() + duration()) | 4649 if (mediaControllerPosition < startTime() || mediaControllerPosition > start
Time() + duration()) |
4650 return true; | 4650 return true; |
4651 | 4651 |
4652 return false; | 4652 return false; |
4653 } | 4653 } |
4654 | 4654 |
4655 void HTMLMediaElement::prepareMediaFragmentURI() | 4655 void HTMLMediaElement::prepareMediaFragmentURI() |
4656 { | 4656 { |
4657 MediaFragmentURIParser fragmentParser(m_currentSrc); | 4657 MediaFragmentURIParser fragmentParser(m_currentSrc); |
4658 float dur = duration(); | 4658 double dur = duration(); |
4659 | 4659 |
4660 double start = fragmentParser.startTime(); | 4660 double start = fragmentParser.startTime(); |
4661 if (start != MediaFragmentURIParser::invalidTimeValue() && start > 0) { | 4661 if (start != MediaFragmentURIParser::invalidTimeValue() && start > 0) { |
4662 m_fragmentStartTime = start; | 4662 m_fragmentStartTime = start; |
4663 if (m_fragmentStartTime > dur) | 4663 if (m_fragmentStartTime > dur) |
4664 m_fragmentStartTime = dur; | 4664 m_fragmentStartTime = dur; |
4665 } else | 4665 } else |
4666 m_fragmentStartTime = MediaPlayer::invalidTime(); | 4666 m_fragmentStartTime = MediaPlayer::invalidTime(); |
4667 | 4667 |
4668 double end = fragmentParser.endTime(); | 4668 double end = fragmentParser.endTime(); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4851 info.addMember(m_sleepDisabler, "sleepDisabler"); | 4851 info.addMember(m_sleepDisabler, "sleepDisabler"); |
4852 #endif | 4852 #endif |
4853 #if ENABLE(WEB_AUDIO) | 4853 #if ENABLE(WEB_AUDIO) |
4854 info.addMember(m_audioSourceNode, "audioSourceNode"); | 4854 info.addMember(m_audioSourceNode, "audioSourceNode"); |
4855 #endif | 4855 #endif |
4856 | 4856 |
4857 } | 4857 } |
4858 | 4858 |
4859 } | 4859 } |
4860 #endif | 4860 #endif |
OLD | NEW |