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

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

Issue 530993002: WebMediaPlayerImpl should notify ended event Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 3 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 | « Source/core/html/HTMLMediaElement.h ('k') | Source/platform/graphics/media/MediaPlayer.h » ('j') | 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 3095 matching lines...) Expand 10 before | Expand all | Expand 10 after
3106 3106
3107 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek. 3107 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek.
3108 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king()) 3108 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king())
3109 finishSeek(); 3109 finishSeek();
3110 3110
3111 // Always call scheduleTimeupdateEvent when the media engine reports a time discontinuity, 3111 // Always call scheduleTimeupdateEvent when the media engine reports a time discontinuity,
3112 // it will only queue a 'timeupdate' event if we haven't already posted one at the current 3112 // it will only queue a 'timeupdate' event if we haven't already posted one at the current
3113 // movie time. 3113 // movie time.
3114 scheduleTimeupdateEvent(false); 3114 scheduleTimeupdateEvent(false);
3115 3115
3116 // TODO(amogh.bihani): Remove this once chromium change lands (codereview.ch romium.org/533543004/).
3116 double now = currentTime(); 3117 double now = currentTime();
3117 double dur = duration(); 3118 double dur = duration();
3118 3119
3120 if (!std::isnan(dur) && dur && now >= dur && directionOfPlayback() == Forwar d)
3121 mediaPlayerEnded();
3122
3123 updatePlayState();
3124 }
3125
3126 void HTMLMediaElement::mediaPlayerEnded()
3127 {
3128 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerEnded");
3129
3119 // When the current playback position reaches the end of the media resource when the direction of 3130 // When the current playback position reaches the end of the media resource when the direction of
3120 // playback is forwards, then the user agent must follow these steps: 3131 // playback is forwards, then the user agent must follow these steps:
3121 if (!std::isnan(dur) && dur && now >= dur && directionOfPlayback() == Forwar d) { 3132 if (!std::isnan(duration()) && directionOfPlayback() == Forward) {
3122 // If the media element has a loop attribute specified and does not have a current media controller, 3133 // If the media element has a loop attribute specified and does not have a current media controller,
3123 if (loop() && !m_mediaController) { 3134 if (loop() && !m_mediaController) {
3124 m_sentEndEvent = false; 3135 m_sentEndEvent = false;
3125 // then seek to the earliest possible position of the media resourc e and abort these steps. 3136 // then seek to the earliest possible position of the media resourc e and abort these steps.
3126 seek(0); 3137 seek(0);
3127 } else { 3138 } else {
3128 // If the media element does not have a current media controller, an d the media element 3139 // If the media element does not have a current media controller, an d the media element
3129 // has still ended playback, and the direction of playback is still forwards, and paused 3140 // has still ended playback, and the direction of playback is still forwards, and paused
3130 // is false, 3141 // is false,
3131 if (!m_mediaController && !m_paused) { 3142 if (!m_mediaController && !m_paused) {
3132 // changes paused to true and fires a simple event named pause a t the media element. 3143 // changes paused to true and fires a simple event named pause a t the media element.
3133 m_paused = true; 3144 m_paused = true;
3134 scheduleEvent(EventTypeNames::pause); 3145 scheduleEvent(EventTypeNames::pause);
3135 } 3146 }
3136 // Queue a task to fire a simple event named ended at the media elem ent. 3147 // Queue a task to fire a simple event named ended at the media elem ent.
3137 if (!m_sentEndEvent) { 3148 if (!m_sentEndEvent) {
3138 m_sentEndEvent = true; 3149 m_sentEndEvent = true;
3139 scheduleEvent(EventTypeNames::ended); 3150 scheduleEvent(EventTypeNames::ended);
3140 } 3151 }
3141 // If the media element has a current media controller, then report the controller state 3152 // If the media element has a current media controller, then report the controller state
3142 // for the media element's current media controller. 3153 // for the media element's current media controller.
3143 updateMediaController(); 3154 updateMediaController();
3144 } 3155 }
3156 } else {
3157 m_sentEndEvent = false;
3145 } 3158 }
3146 else
3147 m_sentEndEvent = false;
3148 3159
3149 updatePlayState(); 3160 updatePlayState();
3150 } 3161 }
3151 3162
3152 void HTMLMediaElement::mediaPlayerDurationChanged() 3163 void HTMLMediaElement::mediaPlayerDurationChanged()
3153 { 3164 {
3154 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged(%p)", this); 3165 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged(%p)", this);
3166 refreshCachedTime();
3155 // FIXME: Change MediaPlayerClient & WebMediaPlayer to convey 3167 // FIXME: Change MediaPlayerClient & WebMediaPlayer to convey
3156 // the currentTime when the duration change occured. The current 3168 // the currentTime when the duration change occured. The current
3157 // WebMediaPlayer implementations always clamp currentTime() to 3169 // WebMediaPlayer implementations always clamp currentTime() to
3158 // duration() so the requestSeek condition here is always false. 3170 // duration() so the requestSeek condition here is always false.
3159 durationChanged(duration(), currentTime() > duration()); 3171 durationChanged(duration(), currentTime() > duration());
3160 } 3172 }
3161 3173
3162 void HTMLMediaElement::durationChanged(double duration, bool requestSeek) 3174 void HTMLMediaElement::durationChanged(double duration, bool requestSeek)
3163 { 3175 {
3164 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p, %f, %d)", this, durati on, requestSeek); 3176 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p, %f, %d)", this, durati on, requestSeek);
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
4009 4021
4010 #if ENABLE(WEB_AUDIO) 4022 #if ENABLE(WEB_AUDIO)
4011 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 4023 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
4012 { 4024 {
4013 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) 4025 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider())
4014 audioSourceProvider()->setClient(0); 4026 audioSourceProvider()->setClient(0);
4015 } 4027 }
4016 #endif 4028 #endif
4017 4029
4018 } 4030 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | Source/platform/graphics/media/MediaPlayer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698