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

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

Issue 2440563004: Switch to using an explicit ended signal instead of time comparison. (Closed)
Patch Set: Fix ended event in ARI. Created 4 years, 2 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 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 2961 matching lines...) Expand 10 before | Expand all | Expand 10 after
2972 // spec says: 2972 // spec says:
2973 // 4.8.8 - Dynamically modifying a source element and its attribute when the 2973 // 4.8.8 - Dynamically modifying a source element and its attribute when the
2974 // element is already inserted in a video or audio element will have no 2974 // element is already inserted in a video or audio element will have no
2975 // effect. 2975 // effect.
2976 m_currentSourceNode = nullptr; 2976 m_currentSourceNode = nullptr;
2977 BLINK_MEDIA_LOG << "sourceWasRemoved(" << (void*)this 2977 BLINK_MEDIA_LOG << "sourceWasRemoved(" << (void*)this
2978 << ") - m_currentSourceNode set to 0"; 2978 << ") - m_currentSourceNode set to 0";
2979 } 2979 }
2980 } 2980 }
2981 2981
2982 void HTMLMediaElement::timeChanged() { 2982 void HTMLMediaElement::timeChanged(bool ended) {
2983 BLINK_MEDIA_LOG << "timeChanged(" << (void*)this << ")"; 2983 BLINK_MEDIA_LOG << "timeChanged(" << (void*)this << ")";
2984 2984
2985 cueTimeline().updateActiveCues(currentTime()); 2985 cueTimeline().updateActiveCues(currentTime());
2986 2986
2987 invalidateCachedTime(); 2987 invalidateCachedTime();
2988 2988
2989 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with the 2989 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with the
2990 // seek. 2990 // seek.
2991 if (m_seeking && m_readyState >= kHaveCurrentData && 2991 if (m_seeking && m_readyState >= kHaveCurrentData &&
2992 !webMediaPlayer()->seeking()) 2992 !webMediaPlayer()->seeking())
2993 finishSeek(); 2993 finishSeek();
2994 2994
2995 // Always call scheduleTimeupdateEvent when the media engine reports a time 2995 // Always call scheduleTimeupdateEvent when the media engine reports a time
2996 // discontinuity, it will only queue a 'timeupdate' event if we haven't 2996 // discontinuity, it will only queue a 'timeupdate' event if we haven't
2997 // already posted one at the current movie time. 2997 // already posted one at the current movie time.
2998 scheduleTimeupdateEvent(false); 2998 scheduleTimeupdateEvent(false);
2999 2999
3000 double now = currentTime(); 3000 if (ended) {
3001 double dur = duration();
3002
3003 // When the current playback position reaches the end of the media resource
3004 // when the direction of playback is forwards, then the user agent must follow
3005 // these steps:
3006 if (!std::isnan(dur) && dur && now >= dur &&
3007 getDirectionOfPlayback() == Forward) {
3008 // If the media element has a loop attribute specified 3001 // If the media element has a loop attribute specified
3009 if (loop()) { 3002 if (loop()) {
3010 // then seek to the earliest possible position of the media resource and 3003 // then seek to the earliest possible position of the media resource and
3011 // abort these steps. 3004 // abort these steps.
3012 seek(0); 3005 seek(0);
3013 } else { 3006 } else {
3014 // If the media element has still ended playback, and the direction of 3007 // If the media element has still ended playback, and the direction of
3015 // playback is still forwards, and paused is false, 3008 // playback is still forwards, and paused is false,
3016 if (!m_paused) { 3009 if (!m_paused) {
3017 // changes paused to true and fires a simple event named pause at the 3010 // changes paused to true and fires a simple event named pause at the
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
3191 // A media element is said to have ended playback when the element's 3184 // A media element is said to have ended playback when the element's
3192 // readyState attribute is HAVE_METADATA or greater, 3185 // readyState attribute is HAVE_METADATA or greater,
3193 if (m_readyState < kHaveMetadata) 3186 if (m_readyState < kHaveMetadata)
3194 return false; 3187 return false;
3195 3188
3196 // and the current playback position is the end of the media resource and the 3189 // and the current playback position is the end of the media resource and the
3197 // direction of playback is forwards, Either the media element does not have a 3190 // direction of playback is forwards, Either the media element does not have a
3198 // loop attribute specified, 3191 // loop attribute specified,
3199 double now = currentTime(); 3192 double now = currentTime();
3200 if (getDirectionOfPlayback() == Forward) 3193 if (getDirectionOfPlayback() == Forward)
3201 return dur > 0 && now >= dur && 3194 return dur > 0 && now >= dur &&
chcunningham 2016/10/24 22:48:41 currentTime is still being compared to duration he
DaleCurtis 2016/10/24 23:29:44 Ah, good find. This is becoming problematic since
3202 (loopCondition == LoopCondition::Ignored || !loop()); 3195 (loopCondition == LoopCondition::Ignored || !loop());
3203 3196
3204 // or the current playback position is the earliest possible position and the 3197 // or the current playback position is the earliest possible position and the
3205 // direction of playback is backwards 3198 // direction of playback is backwards
3206 DCHECK_EQ(getDirectionOfPlayback(), Backward); 3199 DCHECK_EQ(getDirectionOfPlayback(), Backward);
3207 return now <= 0; 3200 return now <= 0;
3208 } 3201 }
3209 3202
3210 bool HTMLMediaElement::stoppedDueToErrors() const { 3203 bool HTMLMediaElement::stoppedDueToErrors() const {
3211 if (m_readyState >= kHaveMetadata && m_error) { 3204 if (m_readyState >= kHaveMetadata && m_error) {
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
4092 4085
4093 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() 4086 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect()
4094 const { 4087 const {
4095 IntRect result; 4088 IntRect result;
4096 if (LayoutObject* object = m_element->layoutObject()) 4089 if (LayoutObject* object = m_element->layoutObject())
4097 result = object->absoluteBoundingBoxRect(); 4090 result = object->absoluteBoundingBoxRect();
4098 return result; 4091 return result;
4099 } 4092 }
4100 4093
4101 } // namespace blink 4094 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMediaElement.h ('k') | third_party/WebKit/public/platform/WebMediaPlayerClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698