OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 { | 44 { |
45 return adoptRef(new MediaController(context)); | 45 return adoptRef(new MediaController(context)); |
46 } | 46 } |
47 | 47 |
48 MediaController::MediaController(ExecutionContext* context) | 48 MediaController::MediaController(ExecutionContext* context) |
49 : m_paused(false) | 49 : m_paused(false) |
50 , m_defaultPlaybackRate(1) | 50 , m_defaultPlaybackRate(1) |
51 , m_volume(1) | 51 , m_volume(1) |
52 , m_position(MediaPlayer::invalidTime()) | 52 , m_position(MediaPlayer::invalidTime()) |
53 , m_muted(false) | 53 , m_muted(false) |
54 , m_readyState(HAVE_NOTHING) | 54 , m_readyState(HTMLMediaElement::HAVE_NOTHING) |
55 , m_playbackState(WAITING) | 55 , m_playbackState(WAITING) |
56 , m_asyncEventTimer(this, &MediaController::asyncEventTimerFired) | 56 , m_asyncEventTimer(this, &MediaController::asyncEventTimerFired) |
57 , m_clearPositionTimer(this, &MediaController::clearPositionTimerFired) | 57 , m_clearPositionTimer(this, &MediaController::clearPositionTimerFired) |
58 , m_closedCaptionsVisible(false) | 58 , m_closedCaptionsVisible(false) |
59 , m_clock(Clock::create()) | 59 , m_clock(Clock::create()) |
60 , m_executionContext(context) | 60 , m_executionContext(context) |
61 , m_timeupdateTimer(this, &MediaController::timeupdateTimerFired) | 61 , m_timeupdateTimer(this, &MediaController::timeupdateTimerFired) |
62 , m_previousTimeupdateTime(0) | 62 , m_previousTimeupdateTime(0) |
63 { | 63 { |
64 ScriptWrappable::init(this); | 64 ScriptWrappable::init(this); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 return nullAtom; | 324 return nullAtom; |
325 } | 325 } |
326 } | 326 } |
327 | 327 |
328 void MediaController::reportControllerState() | 328 void MediaController::reportControllerState() |
329 { | 329 { |
330 updateReadyState(); | 330 updateReadyState(); |
331 updatePlaybackState(); | 331 updatePlaybackState(); |
332 } | 332 } |
333 | 333 |
334 static AtomicString eventNameForReadyState(MediaControllerInterface::ReadyState
state) | 334 static const AtomicString& eventNameForReadyState(HTMLMediaElement::ReadyState s
tate) |
335 { | 335 { |
336 switch (state) { | 336 switch (state) { |
337 case MediaControllerInterface::HAVE_NOTHING: | 337 case HTMLMediaElement::HAVE_NOTHING: |
338 return EventTypeNames::emptied; | 338 return EventTypeNames::emptied; |
339 case MediaControllerInterface::HAVE_METADATA: | 339 case HTMLMediaElement::HAVE_METADATA: |
340 return EventTypeNames::loadedmetadata; | 340 return EventTypeNames::loadedmetadata; |
341 case MediaControllerInterface::HAVE_CURRENT_DATA: | 341 case HTMLMediaElement::HAVE_CURRENT_DATA: |
342 return EventTypeNames::loadeddata; | 342 return EventTypeNames::loadeddata; |
343 case MediaControllerInterface::HAVE_FUTURE_DATA: | 343 case HTMLMediaElement::HAVE_FUTURE_DATA: |
344 return EventTypeNames::canplay; | 344 return EventTypeNames::canplay; |
345 case MediaControllerInterface::HAVE_ENOUGH_DATA: | 345 case HTMLMediaElement::HAVE_ENOUGH_DATA: |
346 return EventTypeNames::canplaythrough; | 346 return EventTypeNames::canplaythrough; |
347 default: | 347 default: |
348 ASSERT_NOT_REACHED(); | 348 ASSERT_NOT_REACHED(); |
349 return nullAtom; | 349 return nullAtom; |
350 } | 350 } |
351 } | 351 } |
352 | 352 |
353 void MediaController::updateReadyState() | 353 void MediaController::updateReadyState() |
354 { | 354 { |
355 ReadyState oldReadyState = m_readyState; | 355 ReadyState oldReadyState = m_readyState; |
356 ReadyState newReadyState; | 356 ReadyState newReadyState; |
357 | 357 |
358 if (m_mediaElements.isEmpty()) { | 358 if (m_mediaElements.isEmpty()) { |
359 // If the MediaController has no slaved media elements, let new readines
s state be 0. | 359 // If the MediaController has no slaved media elements, let new readines
s state be 0. |
360 newReadyState = HAVE_NOTHING; | 360 newReadyState = HTMLMediaElement::HAVE_NOTHING; |
361 } else { | 361 } else { |
362 // Otherwise, let it have the lowest value of the readyState IDL attribu
tes of all of its | 362 // Otherwise, let it have the lowest value of the readyState IDL attribu
tes of all of its |
363 // slaved media elements. | 363 // slaved media elements. |
364 newReadyState = m_mediaElements.first()->readyState(); | 364 newReadyState = m_mediaElements.first()->readyState(); |
365 for (size_t index = 1; index < m_mediaElements.size(); ++index) | 365 for (size_t index = 1; index < m_mediaElements.size(); ++index) |
366 newReadyState = min(newReadyState, m_mediaElements[index]->readyStat
e()); | 366 newReadyState = min(newReadyState, m_mediaElements[index]->readyStat
e()); |
367 } | 367 } |
368 | 368 |
369 if (newReadyState == oldReadyState) | 369 if (newReadyState == oldReadyState) |
370 return; | 370 return; |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 { | 654 { |
655 double now = WTF::currentTime(); | 655 double now = WTF::currentTime(); |
656 double timedelta = now - m_previousTimeupdateTime; | 656 double timedelta = now - m_previousTimeupdateTime; |
657 | 657 |
658 if (timedelta < maxTimeupdateEventFrequency) | 658 if (timedelta < maxTimeupdateEventFrequency) |
659 return; | 659 return; |
660 | 660 |
661 scheduleEvent(EventTypeNames::timeupdate); | 661 scheduleEvent(EventTypeNames::timeupdate); |
662 m_previousTimeupdateTime = now; | 662 m_previousTimeupdateTime = now; |
663 } | 663 } |
OLD | NEW |