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 1895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1906 refreshCachedTime(); | 1906 refreshCachedTime(); |
1907 double now = currentTime(); | 1907 double now = currentTime(); |
1908 | 1908 |
1909 // 2 - If the element's seeking IDL attribute is true, then another instance
of this algorithm is | 1909 // 2 - If the element's seeking IDL attribute is true, then another instance
of this algorithm is |
1910 // already running. Abort that other instance of the algorithm without waiti
ng for the step that | 1910 // already running. Abort that other instance of the algorithm without waiti
ng for the step that |
1911 // it is running to complete. | 1911 // it is running to complete. |
1912 // Nothing specific to be done here. | 1912 // Nothing specific to be done here. |
1913 | 1913 |
1914 // 3 - Set the seeking IDL attribute to true. | 1914 // 3 - Set the seeking IDL attribute to true. |
1915 // The flag will be cleared when the engine tells us the time has actually c
hanged. | 1915 // The flag will be cleared when the engine tells us the time has actually c
hanged. |
1916 bool previousSeekStillPending = m_seeking; | |
1917 m_seeking = true; | 1916 m_seeking = true; |
1918 | 1917 |
1919 // 5 - If the new playback position is later than the end of the media resou
rce, then let it be the end | 1918 // 5 - If the new playback position is later than the end of the media resou
rce, then let it be the end |
1920 // of the media resource instead. | 1919 // of the media resource instead. |
1921 time = std::min(time, duration()); | 1920 time = std::min(time, duration()); |
1922 | 1921 |
1923 // 6 - If the new playback position is less than the earliest possible posit
ion, let it be that position instead. | 1922 // 6 - If the new playback position is less than the earliest possible posit
ion, let it be that position instead. |
1924 time = std::max(time, 0.0); | 1923 time = std::max(time, 0.0); |
1925 | 1924 |
1926 // Ask the media engine for the time value in the movie's time scale before
comparing with current time. This | 1925 // Ask the media engine for the time value in the movie's time scale before
comparing with current time. This |
1927 // is necessary because if the seek time is not equal to currentTime but the
delta is less than the movie's | 1926 // is necessary because if the seek time is not equal to currentTime but the
delta is less than the movie's |
1928 // time scale, we will ask the media engine to "seek" to the current movie t
ime, which may be a noop and | 1927 // time scale, we will ask the media engine to "seek" to the current movie t
ime, which may be a noop and |
1929 // not generate a timechanged callback. This means m_seeking will never be c
leared and we will never | 1928 // not generate a timechanged callback. This means m_seeking will never be c
leared and we will never |
1930 // fire a 'seeked' event. | 1929 // fire a 'seeked' event. |
1931 double mediaTime = webMediaPlayer()->mediaTimeForTimeValue(time); | 1930 double mediaTime = webMediaPlayer()->mediaTimeForTimeValue(time); |
1932 if (time != mediaTime) { | 1931 if (time != mediaTime) { |
1933 WTF_LOG(Media, "HTMLMediaElement::seek(%f) - media timeline equivalent i
s %f", time, mediaTime); | 1932 WTF_LOG(Media, "HTMLMediaElement::seek(%f) - media timeline equivalent i
s %f", time, mediaTime); |
1934 time = mediaTime; | 1933 time = mediaTime; |
1935 } | 1934 } |
1936 | 1935 |
1937 // 7 - If the (possibly now changed) new playback position is not in one of
the ranges given in the | 1936 // 7 - If the (possibly now changed) new playback position is not in one of
the ranges given in the |
1938 // seekable attribute, then let it be the position in one of the ranges give
n in the seekable attribute | 1937 // seekable attribute, then let it be the position in one of the ranges give
n in the seekable attribute |
1939 // that is the nearest to the new playback position. ... If there are no ran
ges given in the seekable | 1938 // that is the nearest to the new playback position. ... If there are no ran
ges given in the seekable |
1940 // attribute then set the seeking IDL attribute to false and abort these ste
ps. | 1939 // attribute then set the seeking IDL attribute to false and abort these ste
ps. |
1941 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable(); | 1940 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable(); |
1942 | 1941 |
1943 // Short circuit seeking to the current time by just firing the events if no
seek is required. | 1942 if (!seekableRanges->length()) { |
1944 // Don't skip calling the media engine if we are in poster mode because a se
ek should always | |
1945 // cancel poster display. | |
1946 bool noSeekRequired = !seekableRanges->length() || (time == now && displayMo
de() != Poster); | |
1947 | |
1948 if (noSeekRequired) { | |
1949 if (time == now) { | |
1950 scheduleEvent(EventTypeNames::seeking); | |
1951 if (previousSeekStillPending) | |
1952 return; | |
1953 // FIXME: There must be a stable state before timeupdate+seeked are
dispatched and seeking | |
1954 // is reset to false. See http://crbug.com/266631 | |
1955 scheduleTimeupdateEvent(false); | |
1956 scheduleEvent(EventTypeNames::seeked); | |
1957 } | |
1958 m_seeking = false; | 1943 m_seeking = false; |
1959 return; | 1944 return; |
1960 } | 1945 } |
| 1946 |
1961 time = seekableRanges->nearest(time); | 1947 time = seekableRanges->nearest(time); |
1962 | 1948 |
1963 if (m_playing) { | 1949 if (m_playing && m_lastSeekTime < now) |
1964 if (m_lastSeekTime < now) | 1950 addPlayedRange(m_lastSeekTime, now); |
1965 addPlayedRange(m_lastSeekTime, now); | 1951 |
1966 } | |
1967 m_lastSeekTime = time; | 1952 m_lastSeekTime = time; |
1968 m_sentEndEvent = false; | 1953 m_sentEndEvent = false; |
1969 | 1954 |
1970 // 8 - Queue a task to fire a simple event named seeking at the element. | 1955 // 8 - Queue a task to fire a simple event named seeking at the element. |
1971 scheduleEvent(EventTypeNames::seeking); | 1956 scheduleEvent(EventTypeNames::seeking); |
1972 | 1957 |
1973 // 9 - Set the current playback position to the given new playback position | 1958 // 9 - Set the current playback position to the given new playback position |
1974 webMediaPlayer()->seek(time); | 1959 webMediaPlayer()->seek(time); |
1975 | 1960 |
1976 // 10-14 are handled, if necessary, when the engine signals a readystate cha
nge or otherwise | 1961 // 10-14 are handled, if necessary, when the engine signals a readystate cha
nge or otherwise |
(...skipping 1986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3963 | 3948 |
3964 #if ENABLE(WEB_AUDIO) | 3949 #if ENABLE(WEB_AUDIO) |
3965 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 3950 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
3966 { | 3951 { |
3967 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) | 3952 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) |
3968 audioSourceProvider()->setClient(0); | 3953 audioSourceProvider()->setClient(0); |
3969 } | 3954 } |
3970 #endif | 3955 #endif |
3971 | 3956 |
3972 } | 3957 } |
OLD | NEW |