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

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: removing use of m_sentEndEvent 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 3055 matching lines...) Expand 10 before | Expand all | Expand 10 after
3066 3066
3067 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek. 3067 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek.
3068 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king()) 3068 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king())
3069 finishSeek(); 3069 finishSeek();
3070 3070
3071 // Always call scheduleTimeupdateEvent when the media engine reports a time discontinuity, 3071 // Always call scheduleTimeupdateEvent when the media engine reports a time discontinuity,
3072 // it will only queue a 'timeupdate' event if we haven't already posted one at the current 3072 // it will only queue a 'timeupdate' event if we haven't already posted one at the current
3073 // movie time. 3073 // movie time.
3074 scheduleTimeupdateEvent(false); 3074 scheduleTimeupdateEvent(false);
3075 3075
3076 // TODO(amogh.bihani): Remove this once chromium change lands (codereview.ch romium.org/533543004/).
3076 double now = currentTime(); 3077 double now = currentTime();
3077 double dur = duration(); 3078 double dur = duration();
3078 3079
3080 if (!std::isnan(dur) && dur && now >= dur && directionOfPlayback() == Forwar d)
philipj_slow 2014/09/10 13:11:08 This is also temporary, to be removed after codere
amogh.bihani 2014/09/10 13:39:22 Yes.
3081 mediaPlayerEnded();
3082
3083 updatePlayState();
3084 }
3085
3086 void HTMLMediaElement::mediaPlayerEnded()
philipj_slow 2014/09/10 13:24:35 Do you intend to clamp duration to currentTime som
amogh.bihani 2014/09/10 13:39:22 I am planning to clamp it in webmediaplayer_impl s
3087 {
3088 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerEnded");
philipj_slow 2014/09/10 13:11:08 There was a recent patch to add the this pointer t
amogh.bihani 2014/09/10 13:39:22 Acknowledged.
3089
3079 // When the current playback position reaches the end of the media resource when the direction of 3090 // When the current playback position reaches the end of the media resource when the direction of
3080 // playback is forwards, then the user agent must follow these steps: 3091 // playback is forwards, then the user agent must follow these steps:
3081 if (!std::isnan(dur) && dur && now >= dur && directionOfPlayback() == Forwar d) { 3092 if (!std::isnan(duration()) && directionOfPlayback() == Forward) {
3082 // If the media element has a loop attribute specified and does not have a current media controller, 3093 // If the media element has a loop attribute specified and does not have a current media controller,
3083 if (loop() && !m_mediaController) { 3094 if (loop() && !m_mediaController) {
3084 m_sentEndEvent = false; 3095 m_sentEndEvent = false;
3085 // then seek to the earliest possible position of the media resourc e and abort these steps. 3096 // then seek to the earliest possible position of the media resourc e and abort these steps.
3086 seek(0, IGNORE_EXCEPTION); 3097 seek(0, IGNORE_EXCEPTION);
3087 } else { 3098 } else {
3088 // If the media element does not have a current media controller, an d the media element 3099 // If the media element does not have a current media controller, an d the media element
3089 // has still ended playback, and the direction of playback is still forwards, and paused 3100 // has still ended playback, and the direction of playback is still forwards, and paused
3090 // is false, 3101 // is false,
3091 if (!m_mediaController && !m_paused) { 3102 if (!m_mediaController && !m_paused) {
3092 // changes paused to true and fires a simple event named pause a t the media element. 3103 // changes paused to true and fires a simple event named pause a t the media element.
3093 m_paused = true; 3104 m_paused = true;
3094 scheduleEvent(EventTypeNames::pause); 3105 scheduleEvent(EventTypeNames::pause);
3095 } 3106 }
3096 // Queue a task to fire a simple event named ended at the media elem ent. 3107 // Queue a task to fire a simple event named ended at the media elem ent.
3097 if (!m_sentEndEvent) { 3108 if (!m_sentEndEvent) {
3098 m_sentEndEvent = true; 3109 m_sentEndEvent = true;
3099 scheduleEvent(EventTypeNames::ended); 3110 scheduleEvent(EventTypeNames::ended);
3100 } 3111 }
3101 // If the media element has a current media controller, then report the controller state 3112 // If the media element has a current media controller, then report the controller state
3102 // for the media element's current media controller. 3113 // for the media element's current media controller.
3103 updateMediaController(); 3114 updateMediaController();
3104 } 3115 }
3116 } else {
3117 m_sentEndEvent = false;
3105 } 3118 }
3106 else
3107 m_sentEndEvent = false;
3108 3119
3109 updatePlayState(); 3120 updatePlayState();
3110 } 3121 }
3111 3122
3112 void HTMLMediaElement::mediaPlayerDurationChanged() 3123 void HTMLMediaElement::mediaPlayerDurationChanged()
3113 { 3124 {
3114 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged(%p)", this); 3125 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged(%p)", this);
3126 refreshCachedTime();
philipj_slow 2014/09/10 13:11:08 This looks correct, but is it related to the other
amogh.bihani 2014/09/10 13:39:22 It is related to the changes done in chromium side
3115 // FIXME: Change MediaPlayerClient & WebMediaPlayer to convey 3127 // FIXME: Change MediaPlayerClient & WebMediaPlayer to convey
3116 // the currentTime when the duration change occured. The current 3128 // the currentTime when the duration change occured. The current
3117 // WebMediaPlayer implementations always clamp currentTime() to 3129 // WebMediaPlayer implementations always clamp currentTime() to
3118 // duration() so the requestSeek condition here is always false. 3130 // duration() so the requestSeek condition here is always false.
3119 durationChanged(duration(), currentTime() > duration()); 3131 durationChanged(duration(), currentTime() > duration());
3120 } 3132 }
3121 3133
3122 void HTMLMediaElement::durationChanged(double duration, bool requestSeek) 3134 void HTMLMediaElement::durationChanged(double duration, bool requestSeek)
3123 { 3135 {
3124 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p, %f, %d)", this, durati on, requestSeek); 3136 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p, %f, %d)", this, durati on, requestSeek);
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
3970 3982
3971 #if ENABLE(WEB_AUDIO) 3983 #if ENABLE(WEB_AUDIO)
3972 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 3984 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
3973 { 3985 {
3974 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) 3986 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider())
3975 audioSourceProvider()->setClient(0); 3987 audioSourceProvider()->setClient(0);
3976 } 3988 }
3977 #endif 3989 #endif
3978 3990
3979 } 3991 }
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