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

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

Issue 431903003: Always notify the MediaPlayer of any seek. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Modified on top of acolwell's patch Created 6 years, 4 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
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 1919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1930 refreshCachedTime(); 1930 refreshCachedTime();
1931 double now = currentTime(); 1931 double now = currentTime();
1932 1932
1933 // 2 - If the element's seeking IDL attribute is true, then another instance of this algorithm is 1933 // 2 - If the element's seeking IDL attribute is true, then another instance of this algorithm is
1934 // already running. Abort that other instance of the algorithm without waiti ng for the step that 1934 // already running. Abort that other instance of the algorithm without waiti ng for the step that
1935 // it is running to complete. 1935 // it is running to complete.
1936 // Nothing specific to be done here. 1936 // Nothing specific to be done here.
1937 1937
1938 // 3 - Set the seeking IDL attribute to true. 1938 // 3 - Set the seeking IDL attribute to true.
1939 // The flag will be cleared when the engine tells us the time has actually c hanged. 1939 // The flag will be cleared when the engine tells us the time has actually c hanged.
1940 bool previousSeekStillPending = m_seeking;
1941 m_seeking = true; 1940 m_seeking = true;
1942 1941
1943 // 5 - If the new playback position is later than the end of the media resou rce, then let it be the end 1942 // 5 - If the new playback position is later than the end of the media resou rce, then let it be the end
1944 // of the media resource instead. 1943 // of the media resource instead.
1945 time = std::min(time, duration()); 1944 time = std::min(time, duration());
1946 1945
1947 // 6 - If the new playback position is less than the earliest possible posit ion, let it be that position instead. 1946 // 6 - If the new playback position is less than the earliest possible posit ion, let it be that position instead.
1948 time = std::max(time, 0.0); 1947 time = std::max(time, 0.0);
1949 1948
1950 // Ask the media engine for the time value in the movie's time scale before comparing with current time. This 1949 // Ask the media engine for the time value in the movie's time scale before comparing with current time. This
1951 // is necessary because if the seek time is not equal to currentTime but the delta is less than the movie's 1950 // is necessary because if the seek time is not equal to currentTime but the delta is less than the movie's
1952 // time scale, we will ask the media engine to "seek" to the current movie t ime, which may be a noop and 1951 // time scale, we will ask the media engine to "seek" to the current movie t ime, which may be a noop and
1953 // not generate a timechanged callback. This means m_seeking will never be c leared and we will never 1952 // not generate a timechanged callback. This means m_seeking will never be c leared and we will never
1954 // fire a 'seeked' event. 1953 // fire a 'seeked' event.
1955 double mediaTime = webMediaPlayer()->mediaTimeForTimeValue(time); 1954 double mediaTime = webMediaPlayer()->mediaTimeForTimeValue(time);
1956 if (time != mediaTime) { 1955 if (time != mediaTime) {
1957 WTF_LOG(Media, "HTMLMediaElement::seek(%f) - media timeline equivalent i s %f", time, mediaTime); 1956 WTF_LOG(Media, "HTMLMediaElement::seek(%f) - media timeline equivalent i s %f", time, mediaTime);
1958 time = mediaTime; 1957 time = mediaTime;
1959 } 1958 }
1960 1959
1961 // 7 - If the (possibly now changed) new playback position is not in one of the ranges given in the 1960 // 7 - If the (possibly now changed) new playback position is not in one of the ranges given in the
1962 // seekable attribute, then let it be the position in one of the ranges give n in the seekable attribute 1961 // seekable attribute, then let it be the position in one of the ranges give n in the seekable attribute
1963 // that is the nearest to the new playback position. ... If there are no ran ges given in the seekable 1962 // that is the nearest to the new playback position. ... If there are no ran ges given in the seekable
1964 // attribute then set the seeking IDL attribute to false and abort these ste ps. 1963 // attribute then set the seeking IDL attribute to false and abort these ste ps.
1965 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable(); 1964 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable();
1966 1965
1967 // Short circuit seeking to the current time by just firing the events if no seek is required. 1966 if (!seekableRanges->length()) {
1968 // Don't skip calling the media engine if we are in poster mode because a se ek should always
1969 // cancel poster display.
1970 bool noSeekRequired = !seekableRanges->length() || (time == now && displayMo de() != Poster);
1971
1972 if (noSeekRequired) {
1973 if (time == now) {
1974 scheduleEvent(EventTypeNames::seeking);
1975 if (previousSeekStillPending)
1976 return;
1977 // FIXME: There must be a stable state before timeupdate+seeked are dispatched and seeking
1978 // is reset to false. See http://crbug.com/266631
1979 scheduleTimeupdateEvent(false);
1980 scheduleEvent(EventTypeNames::seeked);
1981 }
1982 m_seeking = false; 1967 m_seeking = false;
1983 return; 1968 return;
1984 } 1969 }
1970
1985 time = seekableRanges->nearest(time); 1971 time = seekableRanges->nearest(time);
1986 1972
1987 if (m_playing) { 1973 if (m_playing && m_lastSeekTime < now)
1988 if (m_lastSeekTime < now) 1974 addPlayedRange(m_lastSeekTime, now);
1989 addPlayedRange(m_lastSeekTime, now); 1975
1990 }
1991 m_lastSeekTime = time; 1976 m_lastSeekTime = time;
1992 m_sentEndEvent = false; 1977 m_sentEndEvent = false;
1993 1978
1994 // 8 - Queue a task to fire a simple event named seeking at the element. 1979 // 8 - Queue a task to fire a simple event named seeking at the element.
1995 scheduleEvent(EventTypeNames::seeking); 1980 scheduleEvent(EventTypeNames::seeking);
1996 1981
1997 // 9 - Set the current playback position to the given new playback position 1982 // 9 - Set the current playback position to the given new playback position
1998 webMediaPlayer()->seek(time); 1983 webMediaPlayer()->seek(time);
1999 1984
2000 // 10-14 are handled, if necessary, when the engine signals a readystate cha nge or otherwise 1985 // 10-14 are handled, if necessary, when the engine signals a readystate cha nge or otherwise
(...skipping 1968 matching lines...) Expand 10 before | Expand all | Expand 10 after
3969 3954
3970 #if ENABLE(WEB_AUDIO) 3955 #if ENABLE(WEB_AUDIO)
3971 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 3956 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
3972 { 3957 {
3973 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) 3958 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider())
3974 audioSourceProvider()->setClient(0); 3959 audioSourceProvider()->setClient(0);
3975 } 3960 }
3976 #endif 3961 #endif
3977 3962
3978 } 3963 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698