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

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

Issue 2499883002: Media Controls: handle 'timeupdate', 'play' and 'pause' via an EventListener. (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | third_party/WebKit/Source/core/html/shadow/MediaControls.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 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 2494 matching lines...) Expand 10 before | Expand all | Expand 10 after
2505 pauseInternal(); 2505 pauseInternal();
2506 } 2506 }
2507 } 2507 }
2508 2508
2509 if (!m_seeking) 2509 if (!m_seeking)
2510 scheduleTimeupdateEvent(true); 2510 scheduleTimeupdateEvent(true);
2511 2511
2512 if (!playbackRate()) 2512 if (!playbackRate())
2513 return; 2513 return;
2514 2514
2515 if (!m_paused && mediaControls())
whywhat 2016/11/15 02:51:08 This seems to only be called when !m_paused but sc
2516 mediaControls()->playbackProgressed();
2517
2518 cueTimeline().updateActiveCues(currentTime()); 2515 cueTimeline().updateActiveCues(currentTime());
2519 } 2516 }
2520 2517
2521 void HTMLMediaElement::scheduleTimeupdateEvent(bool periodicEvent) { 2518 void HTMLMediaElement::scheduleTimeupdateEvent(bool periodicEvent) {
2522 // Per spec, consult current playback position to check for changing time. 2519 // Per spec, consult current playback position to check for changing time.
2523 double mediaTime = currentPlaybackPosition(); 2520 double mediaTime = currentPlaybackPosition();
2524 double now = WTF::currentTime(); 2521 double now = WTF::currentTime();
2525 2522
2526 bool haveNotRecentlyFiredTimeupdate = 2523 bool haveNotRecentlyFiredTimeupdate =
2527 (now - m_lastTimeUpdateEventWallTime) >= maxTimeupdateEventFrequency; 2524 (now - m_lastTimeUpdateEventWallTime) >= maxTimeupdateEventFrequency;
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
3319 if (!isPlaying) { 3316 if (!isPlaying) {
3320 // Set rate, muted before calling play in case they were set before the 3317 // Set rate, muted before calling play in case they were set before the
3321 // media engine was setup. The media engine should just stash the rate 3318 // media engine was setup. The media engine should just stash the rate
3322 // and muted values since it isn't already playing. 3319 // and muted values since it isn't already playing.
3323 webMediaPlayer()->setRate(playbackRate()); 3320 webMediaPlayer()->setRate(playbackRate());
3324 webMediaPlayer()->setVolume(effectiveMediaVolume()); 3321 webMediaPlayer()->setVolume(effectiveMediaVolume());
3325 webMediaPlayer()->play(); 3322 webMediaPlayer()->play();
3326 m_autoplayHelper->playbackStarted(); 3323 m_autoplayHelper->playbackStarted();
3327 } 3324 }
3328 3325
3329 if (mediaControls())
3330 mediaControls()->playbackStarted();
3331 startPlaybackProgressTimer(); 3326 startPlaybackProgressTimer();
3332 m_playing = true; 3327 m_playing = true;
3333
3334 } else { // Should not be playing right now 3328 } else { // Should not be playing right now
3335 if (isPlaying) { 3329 if (isPlaying) {
3336 webMediaPlayer()->pause(); 3330 webMediaPlayer()->pause();
3337 m_autoplayHelper->playbackStopped(); 3331 m_autoplayHelper->playbackStopped();
3338 } 3332 }
3339 3333
3340 m_playbackProgressTimer.stop(); 3334 m_playbackProgressTimer.stop();
3341 m_playing = false; 3335 m_playing = false;
3342 double time = currentTime(); 3336 double time = currentTime();
3343 if (time > m_lastSeekTime) 3337 if (time > m_lastSeekTime)
3344 addPlayedRange(m_lastSeekTime, time); 3338 addPlayedRange(m_lastSeekTime, time);
3345
3346 if (mediaControls())
3347 mediaControls()->playbackStopped();
3348 } 3339 }
3349 3340
3350 if (layoutObject()) 3341 if (layoutObject())
3351 layoutObject()->updateFromElement(); 3342 layoutObject()->updateFromElement();
3352 } 3343 }
3353 3344
3354 void HTMLMediaElement::stopPeriodicTimers() { 3345 void HTMLMediaElement::stopPeriodicTimers() {
3355 m_progressEventTimer.stop(); 3346 m_progressEventTimer.stop();
3356 m_playbackProgressTimer.stop(); 3347 m_playbackProgressTimer.stop();
3357 } 3348 }
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
4164 4155
4165 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() 4156 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect()
4166 const { 4157 const {
4167 IntRect result; 4158 IntRect result;
4168 if (LayoutObject* object = m_element->layoutObject()) 4159 if (LayoutObject* object = m_element->layoutObject())
4169 result = object->absoluteBoundingBoxRect(); 4160 result = object->absoluteBoundingBoxRect();
4170 return result; 4161 return result;
4171 } 4162 }
4172 4163
4173 } // namespace blink 4164 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/shadow/MediaControls.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698