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

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: 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 3075 matching lines...) Expand 10 before | Expand all | Expand 10 after
3086 3086
3087 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek. 3087 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek.
3088 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king()) 3088 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king())
3089 finishSeek(); 3089 finishSeek();
3090 3090
3091 // Always call scheduleTimeupdateEvent when the media engine reports a time discontinuity, 3091 // Always call scheduleTimeupdateEvent when the media engine reports a time discontinuity,
3092 // it will only queue a 'timeupdate' event if we haven't already posted one at the current 3092 // it will only queue a 'timeupdate' event if we haven't already posted one at the current
3093 // movie time. 3093 // movie time.
3094 scheduleTimeupdateEvent(false); 3094 scheduleTimeupdateEvent(false);
3095 3095
3096 // TODO(amogh.bihani): Remove this once chromium change lands.-------------- ---------------------------
3096 double now = currentTime(); 3097 double now = currentTime();
3097 double dur = duration(); 3098 double dur = duration();
3098 3099
3099 // When the current playback position reaches the end of the media resource when the direction of 3100 // When the current playback position reaches the end of the media resource when the direction of
3100 // playback is forwards, then the user agent must follow these steps: 3101 // playback is forwards, then the user agent must follow these steps:
3101 if (!std::isnan(dur) && dur && now >= dur && directionOfPlayback() == Forwar d) { 3102 if (!std::isnan(dur) && dur && now >= dur && directionOfPlayback() == Forwar d) {
3102 // If the media element has a loop attribute specified and does not have a current media controller, 3103 // If the media element has a loop attribute specified and does not have a current media controller,
scherkus (not reviewing) 2014/09/02 20:23:54 is it possible to refactor your new code to call m
amogh.bihani 2014/09/03 05:17:18 Done.
3103 if (loop() && !m_mediaController) { 3104 if (loop() && !m_mediaController) {
3104 m_sentEndEvent = false; 3105 m_sentEndEvent = false;
3105 // then seek to the earliest possible position of the media resourc e and abort these steps. 3106 // then seek to the earliest possible position of the media resourc e and abort these steps.
3106 seek(0, IGNORE_EXCEPTION); 3107 seek(0, IGNORE_EXCEPTION);
3107 } else { 3108 } else {
3108 // If the media element does not have a current media controller, an d the media element 3109 // If the media element does not have a current media controller, an d the media element
3109 // has still ended playback, and the direction of playback is still forwards, and paused 3110 // has still ended playback, and the direction of playback is still forwards, and paused
3110 // is false, 3111 // is false,
3111 if (!m_mediaController && !m_paused) { 3112 if (!m_mediaController && !m_paused) {
3112 // changes paused to true and fires a simple event named pause a t the media element. 3113 // changes paused to true and fires a simple event named pause a t the media element.
3113 m_paused = true; 3114 m_paused = true;
3114 scheduleEvent(EventTypeNames::pause); 3115 scheduleEvent(EventTypeNames::pause);
3115 } 3116 }
3116 // Queue a task to fire a simple event named ended at the media elem ent. 3117 // Queue a task to fire a simple event named ended at the media elem ent.
3117 if (!m_sentEndEvent) { 3118 if (!m_sentEndEvent) {
3118 m_sentEndEvent = true; 3119 m_sentEndEvent = true;
3119 scheduleEvent(EventTypeNames::ended); 3120 scheduleEvent(EventTypeNames::ended);
3120 } 3121 }
3121 // If the media element has a current media controller, then report the controller state 3122 // If the media element has a current media controller, then report the controller state
3122 // for the media element's current media controller. 3123 // for the media element's current media controller.
3123 updateMediaController(); 3124 updateMediaController();
3124 } 3125 }
3125 } 3126 }
3126 else 3127 else
3127 m_sentEndEvent = false; 3128 m_sentEndEvent = false;
3129 // ------------------------------------------------------------------------- ---------------------------
3128 3130
3129 updatePlayState(); 3131 updatePlayState();
3130 } 3132 }
3133
3134 void HTMLMediaElement::mediaPlayerEnded()
scherkus (not reviewing) 2014/09/02 20:23:54 one thing that's tricky is that with this new code
amogh.bihani 2014/09/03 05:17:18 Done.
3135 {
3136 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerEnded");
3137
3138 // When the current playback position reaches the end of the media resource when the direction of
3139 // playback is forwards, then the user agent must follow these steps:
3140 if (!std::isnan(duration()) && directionOfPlayback() == Forward) {
3141 // If the media element has a loop attribute specified and does not have a current media controller,
3142 if (loop() && !m_mediaController) {
3143 m_sentEndEvent = false;
3144 // then seek to the earliest possible position of the media resourc e and abort these steps.
3145 seek(0, IGNORE_EXCEPTION);
3146 } else {
3147 // If the media element does not have a current media controller, an d the media element
3148 // has still ended playback, and the direction of playback is still forwards, and paused
3149 // is false,
3150 if (!m_mediaController && !m_paused) {
3151 // changes paused to true and fires a simple event named pause a t the media element.
3152 m_paused = true;
3153 scheduleEvent(EventTypeNames::pause);
3154 }
3155 // Queue a task to fire a simple event named ended at the media elem ent.
3156 if (!m_sentEndEvent) {
3157 m_sentEndEvent = true;
3158 scheduleEvent(EventTypeNames::ended);
3159 }
3160 // If the media element has a current media controller, then report the controller state
3161 // for the media element's current media controller.
3162 updateMediaController();
3163 }
3164 } else {
3165 m_sentEndEvent = false;
3166 }
3167
3168 updatePlayState();
3169 }
3131 3170
3132 void HTMLMediaElement::mediaPlayerDurationChanged() 3171 void HTMLMediaElement::mediaPlayerDurationChanged()
3133 { 3172 {
3134 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged"); 3173 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged");
3135 // FIXME: Change MediaPlayerClient & WebMediaPlayer to convey 3174 // FIXME: Change MediaPlayerClient & WebMediaPlayer to convey
3136 // the currentTime when the duration change occured. The current 3175 // the currentTime when the duration change occured. The current
3137 // WebMediaPlayer implementations always clamp currentTime() to 3176 // WebMediaPlayer implementations always clamp currentTime() to
3138 // duration() so the requestSeek condition here is always false. 3177 // duration() so the requestSeek condition here is always false.
3139 durationChanged(duration(), currentTime() > duration()); 3178 durationChanged(duration(), currentTime() > duration());
3140 } 3179 }
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
3989 4028
3990 #if ENABLE(WEB_AUDIO) 4029 #if ENABLE(WEB_AUDIO)
3991 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 4030 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
3992 { 4031 {
3993 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) 4032 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider())
3994 audioSourceProvider()->setClient(0); 4033 audioSourceProvider()->setClient(0);
3995 } 4034 }
3996 #endif 4035 #endif
3997 4036
3998 } 4037 }
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