Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: Source/core/html/HTMLMediaElement.cpp

Issue 848853003: Revert of Relanding 'Always notify the MediaPlayer of any seek' patch (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/media/video-seek-to-current-position-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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;
1998 m_seeking = true; 1999 m_seeking = true;
1999 2000
2000 // 6 - If the new playback position is later than the end of the media resou rce, then let it be the end 2001 // 6 - If the new playback position is later than the end of the media resou rce, then let it be the end
2001 // of the media resource instead. 2002 // of the media resource instead.
2002 time = std::min(time, duration()); 2003 time = std::min(time, duration());
2003 2004
2004 // 7 - If the new playback position is less than the earliest possible posit ion, let it be that position instead. 2005 // 7 - If the new playback position is less than the earliest possible posit ion, let it be that position instead.
2005 time = std::max(time, 0.0); 2006 time = std::max(time, 0.0);
2006 2007
2007 // Ask the media engine for the time value in the movie's time scale before comparing with current time. This 2008 // Ask the media engine for the time value in the movie's time scale before comparing with current time. This
2008 // is necessary because if the seek time is not equal to currentTime but the delta is less than the movie's 2009 // is necessary because if the seek time is not equal to currentTime but the delta is less than the movie's
2009 // time scale, we will ask the media engine to "seek" to the current movie t ime, which may be a noop and 2010 // time scale, we will ask the media engine to "seek" to the current movie t ime, which may be a noop and
2010 // not generate a timechanged callback. This means m_seeking will never be c leared and we will never 2011 // not generate a timechanged callback. This means m_seeking will never be c leared and we will never
2011 // fire a 'seeked' event. 2012 // fire a 'seeked' event.
2012 double mediaTime = webMediaPlayer()->mediaTimeForTimeValue(time); 2013 double mediaTime = webMediaPlayer()->mediaTimeForTimeValue(time);
2013 if (time != mediaTime) { 2014 if (time != mediaTime) {
2014 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f) - media timeline equivale nt is %f", this, time, mediaTime); 2015 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f) - media timeline equivale nt is %f", this, time, mediaTime);
2015 time = mediaTime; 2016 time = mediaTime;
2016 } 2017 }
2017 2018
2018 // 8 - If the (possibly now changed) new playback position is not in one of the ranges given in the 2019 // 8 - If the (possibly now changed) new playback position is not in one of the ranges given in the
2019 // seekable attribute, then let it be the position in one of the ranges give n in the seekable attribute 2020 // seekable attribute, then let it be the position in one of the ranges give n in the seekable attribute
2020 // that is the nearest to the new playback position. ... If there are no ran ges given in the seekable 2021 // that is the nearest to the new playback position. ... If there are no ran ges given in the seekable
2021 // attribute then set the seeking IDL attribute to false and abort these ste ps. 2022 // attribute then set the seeking IDL attribute to false and abort these ste ps.
2022 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable(); 2023 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable();
2023 2024
2024 if (!seekableRanges->length()) { 2025 // Short circuit seeking to the current time by just firing the events if no seek is required.
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 }
2025 m_seeking = false; 2040 m_seeking = false;
2026 return; 2041 return;
2027 } 2042 }
2028 time = seekableRanges->nearest(time, now); 2043 time = seekableRanges->nearest(time, now);
2029 2044
2030 if (m_playing && m_lastSeekTime < now) 2045 if (m_playing) {
2031 addPlayedRange(m_lastSeekTime, now); 2046 if (m_lastSeekTime < now)
2032 2047 addPlayedRange(m_lastSeekTime, now);
2048 }
2033 m_lastSeekTime = time; 2049 m_lastSeekTime = time;
2034 m_sentEndEvent = false; 2050 m_sentEndEvent = false;
2035 2051
2036 // 10 - Queue a task to fire a simple event named seeking at the element. 2052 // 10 - Queue a task to fire a simple event named seeking at the element.
2037 scheduleEvent(EventTypeNames::seeking); 2053 scheduleEvent(EventTypeNames::seeking);
2038 2054
2039 // 11 - Set the current playback position to the given new playback position . 2055 // 11 - Set the current playback position to the given new playback position .
2040 webMediaPlayer()->seek(time); 2056 webMediaPlayer()->seek(time);
2041 2057
2042 m_initialPlayWithoutUserGestures = false; 2058 m_initialPlayWithoutUserGestures = false;
(...skipping 2043 matching lines...) Expand 10 before | Expand all | Expand 10 after
4086 4102
4087 #if ENABLE(WEB_AUDIO) 4103 #if ENABLE(WEB_AUDIO)
4088 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 4104 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
4089 { 4105 {
4090 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) 4106 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider())
4091 audioSourceProvider()->setClient(nullptr); 4107 audioSourceProvider()->setClient(nullptr);
4092 } 4108 }
4093 #endif 4109 #endif
4094 4110
4095 } 4111 }
OLDNEW
« no previous file with comments | « LayoutTests/media/video-seek-to-current-position-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698