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 1977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1988 // This is needed to avoid getting default playback start position from curr
entTime(). | 1988 // This is needed to avoid getting default playback start position from curr
entTime(). |
1989 double now = m_cachedTime; | 1989 double now = m_cachedTime; |
1990 | 1990 |
1991 // 3 - If the element's seeking IDL attribute is true, then another instance
of this algorithm is | 1991 // 3 - If the element's seeking IDL attribute is true, then another instance
of this algorithm is |
1992 // already running. Abort that other instance of the algorithm without waiti
ng for the step that | 1992 // already running. Abort that other instance of the algorithm without waiti
ng for the step that |
1993 // it is running to complete. | 1993 // it is running to complete. |
1994 // Nothing specific to be done here. | 1994 // Nothing specific to be done here. |
1995 | 1995 |
1996 // 4 - Set the seeking IDL attribute to true. | 1996 // 4 - Set the seeking IDL attribute to true. |
1997 // The flag will be cleared when the engine tells us the time has actually c
hanged. | 1997 // The flag will be cleared when the engine tells us the time has actually c
hanged. |
1998 bool previousSeekStillPending = m_seeking; | |
1999 m_seeking = true; | 1998 m_seeking = true; |
2000 | 1999 |
2001 // 6 - If the new playback position is later than the end of the media resou
rce, then let it be the end | 2000 // 6 - If the new playback position is later than the end of the media resou
rce, then let it be the end |
2002 // of the media resource instead. | 2001 // of the media resource instead. |
2003 time = std::min(time, duration()); | 2002 time = std::min(time, duration()); |
2004 | 2003 |
2005 // 7 - If the new playback position is less than the earliest possible posit
ion, let it be that position instead. | 2004 // 7 - If the new playback position is less than the earliest possible posit
ion, let it be that position instead. |
2006 time = std::max(time, 0.0); | 2005 time = std::max(time, 0.0); |
2007 | 2006 |
2008 // Ask the media engine for the time value in the movie's time scale before
comparing with current time. This | 2007 // Ask the media engine for the time value in the movie's time scale before
comparing with current time. This |
2009 // is necessary because if the seek time is not equal to currentTime but the
delta is less than the movie's | 2008 // is necessary because if the seek time is not equal to currentTime but the
delta is less than the movie's |
2010 // time scale, we will ask the media engine to "seek" to the current movie t
ime, which may be a noop and | 2009 // time scale, we will ask the media engine to "seek" to the current movie t
ime, which may be a noop and |
2011 // not generate a timechanged callback. This means m_seeking will never be c
leared and we will never | 2010 // not generate a timechanged callback. This means m_seeking will never be c
leared and we will never |
2012 // fire a 'seeked' event. | 2011 // fire a 'seeked' event. |
2013 double mediaTime = webMediaPlayer()->mediaTimeForTimeValue(time); | 2012 double mediaTime = webMediaPlayer()->mediaTimeForTimeValue(time); |
2014 if (time != mediaTime) { | 2013 if (time != mediaTime) { |
2015 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f) - media timeline equivale
nt is %f", this, time, mediaTime); | 2014 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f) - media timeline equivale
nt is %f", this, time, mediaTime); |
2016 time = mediaTime; | 2015 time = mediaTime; |
2017 } | 2016 } |
2018 | 2017 |
2019 // 8 - If the (possibly now changed) new playback position is not in one of
the ranges given in the | 2018 // 8 - If the (possibly now changed) new playback position is not in one of
the ranges given in the |
2020 // seekable attribute, then let it be the position in one of the ranges give
n in the seekable attribute | 2019 // seekable attribute, then let it be the position in one of the ranges give
n in the seekable attribute |
2021 // that is the nearest to the new playback position. ... If there are no ran
ges given in the seekable | 2020 // that is the nearest to the new playback position. ... If there are no ran
ges given in the seekable |
2022 // attribute then set the seeking IDL attribute to false and abort these ste
ps. | 2021 // attribute then set the seeking IDL attribute to false and abort these ste
ps. |
2023 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable(); | 2022 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable(); |
2024 | 2023 |
2025 // Short circuit seeking to the current time by just firing the events if no
seek is required. | 2024 if (!seekableRanges->length()) { |
2026 // Don't skip calling the media engine if we are in poster mode because a se
ek should always | |
2027 // cancel poster display. | |
2028 bool noSeekRequired = !seekableRanges->length() || (time == now && displayMo
de() != Poster); | |
2029 | |
2030 if (noSeekRequired) { | |
2031 if (time == now) { | |
2032 scheduleEvent(EventTypeNames::seeking); | |
2033 if (previousSeekStillPending) | |
2034 return; | |
2035 // FIXME: There must be a stable state before timeupdate+seeked are
dispatched and seeking | |
2036 // is reset to false. See http://crbug.com/266631 | |
2037 scheduleTimeupdateEvent(false); | |
2038 scheduleEvent(EventTypeNames::seeked); | |
2039 } | |
2040 m_seeking = false; | 2025 m_seeking = false; |
2041 return; | 2026 return; |
2042 } | 2027 } |
2043 time = seekableRanges->nearest(time, now); | 2028 time = seekableRanges->nearest(time, now); |
2044 | 2029 |
2045 if (m_playing) { | 2030 if (m_playing && m_lastSeekTime < now) |
2046 if (m_lastSeekTime < now) | 2031 addPlayedRange(m_lastSeekTime, now); |
2047 addPlayedRange(m_lastSeekTime, now); | 2032 |
2048 } | |
2049 m_lastSeekTime = time; | 2033 m_lastSeekTime = time; |
2050 m_sentEndEvent = false; | 2034 m_sentEndEvent = false; |
2051 | 2035 |
2052 // 10 - Queue a task to fire a simple event named seeking at the element. | 2036 // 10 - Queue a task to fire a simple event named seeking at the element. |
2053 scheduleEvent(EventTypeNames::seeking); | 2037 scheduleEvent(EventTypeNames::seeking); |
2054 | 2038 |
2055 // 11 - Set the current playback position to the given new playback position
. | 2039 // 11 - Set the current playback position to the given new playback position
. |
2056 webMediaPlayer()->seek(time); | 2040 webMediaPlayer()->seek(time); |
2057 | 2041 |
2058 m_initialPlayWithoutUserGestures = false; | 2042 m_initialPlayWithoutUserGestures = false; |
(...skipping 2043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4102 | 4086 |
4103 #if ENABLE(WEB_AUDIO) | 4087 #if ENABLE(WEB_AUDIO) |
4104 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 4088 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
4105 { | 4089 { |
4106 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) | 4090 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) |
4107 audioSourceProvider()->setClient(nullptr); | 4091 audioSourceProvider()->setClient(nullptr); |
4108 } | 4092 } |
4109 #endif | 4093 #endif |
4110 | 4094 |
4111 } | 4095 } |
OLD | NEW |