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

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

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

Powered by Google App Engine
This is Rietveld 408576698