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 1950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1961 // This is needed to avoid getting default playback start position from curr
entTime(). | 1961 // This is needed to avoid getting default playback start position from curr
entTime(). |
1962 double now = m_cachedTime; | 1962 double now = m_cachedTime; |
1963 | 1963 |
1964 // 3 - If the element's seeking IDL attribute is true, then another instance
of this algorithm is | 1964 // 3 - If the element's seeking IDL attribute is true, then another instance
of this algorithm is |
1965 // already running. Abort that other instance of the algorithm without waiti
ng for the step that | 1965 // already running. Abort that other instance of the algorithm without waiti
ng for the step that |
1966 // it is running to complete. | 1966 // it is running to complete. |
1967 // Nothing specific to be done here. | 1967 // Nothing specific to be done here. |
1968 | 1968 |
1969 // 4 - Set the seeking IDL attribute to true. | 1969 // 4 - Set the seeking IDL attribute to true. |
1970 // The flag will be cleared when the engine tells us the time has actually c
hanged. | 1970 // The flag will be cleared when the engine tells us the time has actually c
hanged. |
1971 bool previousSeekStillPending = m_seeking; | |
1972 m_seeking = true; | 1971 m_seeking = true; |
1973 | 1972 |
1974 // 6 - If the new playback position is later than the end of the media resou
rce, then let it be the end | 1973 // 6 - If the new playback position is later than the end of the media resou
rce, then let it be the end |
1975 // of the media resource instead. | 1974 // of the media resource instead. |
1976 time = std::min(time, duration()); | 1975 time = std::min(time, duration()); |
1977 | 1976 |
1978 // 7 - If the new playback position is less than the earliest possible posit
ion, let it be that position instead. | 1977 // 7 - If the new playback position is less than the earliest possible posit
ion, let it be that position instead. |
1979 time = std::max(time, 0.0); | 1978 time = std::max(time, 0.0); |
1980 | 1979 |
1981 // Ask the media engine for the time value in the movie's time scale before
comparing with current time. This | 1980 // Ask the media engine for the time value in the movie's time scale before
comparing with current time. This |
1982 // is necessary because if the seek time is not equal to currentTime but the
delta is less than the movie's | 1981 // is necessary because if the seek time is not equal to currentTime but the
delta is less than the movie's |
1983 // time scale, we will ask the media engine to "seek" to the current movie t
ime, which may be a noop and | 1982 // time scale, we will ask the media engine to "seek" to the current movie t
ime, which may be a noop and |
1984 // not generate a timechanged callback. This means m_seeking will never be c
leared and we will never | 1983 // not generate a timechanged callback. This means m_seeking will never be c
leared and we will never |
1985 // fire a 'seeked' event. | 1984 // fire a 'seeked' event. |
1986 double mediaTime = webMediaPlayer()->mediaTimeForTimeValue(time); | 1985 double mediaTime = webMediaPlayer()->mediaTimeForTimeValue(time); |
1987 if (time != mediaTime) { | 1986 if (time != mediaTime) { |
1988 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f) - media timeline equivale
nt is %f", this, time, mediaTime); | 1987 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f) - media timeline equivale
nt is %f", this, time, mediaTime); |
1989 time = mediaTime; | 1988 time = mediaTime; |
1990 } | 1989 } |
1991 | 1990 |
1992 // 8 - If the (possibly now changed) new playback position is not in one of
the ranges given in the | 1991 // 8 - If the (possibly now changed) new playback position is not in one of
the ranges given in the |
1993 // seekable attribute, then let it be the position in one of the ranges give
n in the seekable attribute | 1992 // seekable attribute, then let it be the position in one of the ranges give
n in the seekable attribute |
1994 // that is the nearest to the new playback position. ... If there are no ran
ges given in the seekable | 1993 // that is the nearest to the new playback position. ... If there are no ran
ges given in the seekable |
1995 // attribute then set the seeking IDL attribute to false and abort these ste
ps. | 1994 // attribute then set the seeking IDL attribute to false and abort these ste
ps. |
1996 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable(); | 1995 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable(); |
1997 | 1996 |
1998 // Short circuit seeking to the current time by just firing the events if no
seek is required. | 1997 if (!seekableRanges->length()) { |
1999 // Don't skip calling the media engine if we are in poster mode because a se
ek should always | |
2000 // cancel poster display. | |
2001 bool noSeekRequired = !seekableRanges->length() || (time == now && displayMo
de() != Poster); | |
2002 | |
2003 if (noSeekRequired) { | |
2004 if (time == now) { | |
2005 scheduleEvent(EventTypeNames::seeking); | |
2006 if (previousSeekStillPending) | |
2007 return; | |
2008 // FIXME: There must be a stable state before timeupdate+seeked are
dispatched and seeking | |
2009 // is reset to false. See http://crbug.com/266631 | |
2010 scheduleTimeupdateEvent(false); | |
2011 scheduleEvent(EventTypeNames::seeked); | |
2012 } | |
2013 m_seeking = false; | 1998 m_seeking = false; |
2014 return; | 1999 return; |
2015 } | 2000 } |
2016 time = seekableRanges->nearest(time, now); | 2001 time = seekableRanges->nearest(time, now); |
2017 | 2002 |
2018 if (m_playing) { | 2003 if (m_playing && m_lastSeekTime < now) |
2019 if (m_lastSeekTime < now) | 2004 addPlayedRange(m_lastSeekTime, now); |
2020 addPlayedRange(m_lastSeekTime, now); | 2005 |
2021 } | |
2022 m_lastSeekTime = time; | 2006 m_lastSeekTime = time; |
2023 m_sentEndEvent = false; | 2007 m_sentEndEvent = false; |
2024 | 2008 |
2025 // 10 - Queue a task to fire a simple event named seeking at the element. | 2009 // 10 - Queue a task to fire a simple event named seeking at the element. |
2026 scheduleEvent(EventTypeNames::seeking); | 2010 scheduleEvent(EventTypeNames::seeking); |
2027 | 2011 |
2028 // 11 - Set the current playback position to the given new playback position
. | 2012 // 11 - Set the current playback position to the given new playback position
. |
2029 webMediaPlayer()->seek(time); | 2013 webMediaPlayer()->seek(time); |
2030 | 2014 |
2031 // 14-17 are handled, if necessary, when the engine signals a readystate cha
nge or otherwise | 2015 // 14-17 are handled, if necessary, when the engine signals a readystate cha
nge or otherwise |
(...skipping 1997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4029 | 4013 |
4030 #if ENABLE(WEB_AUDIO) | 4014 #if ENABLE(WEB_AUDIO) |
4031 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 4015 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
4032 { | 4016 { |
4033 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) | 4017 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) |
4034 audioSourceProvider()->setClient(0); | 4018 audioSourceProvider()->setClient(0); |
4035 } | 4019 } |
4036 #endif | 4020 #endif |
4037 | 4021 |
4038 } | 4022 } |
OLD | NEW |