OLD | NEW |
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 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 // a task to fire a simple event named abort at the media element. | 651 // a task to fire a simple event named abort at the media element. |
652 if (m_networkState == NETWORK_LOADING || m_networkState == NETWORK_IDLE) | 652 if (m_networkState == NETWORK_LOADING || m_networkState == NETWORK_IDLE) |
653 scheduleEvent(EventTypeNames::abort); | 653 scheduleEvent(EventTypeNames::abort); |
654 | 654 |
655 closeMediaSource(); | 655 closeMediaSource(); |
656 | 656 |
657 createMediaPlayer(); | 657 createMediaPlayer(); |
658 | 658 |
659 // 4 - If the media element's networkState is not set to NETWORK_EMPTY, then
run these substeps | 659 // 4 - If the media element's networkState is not set to NETWORK_EMPTY, then
run these substeps |
660 if (m_networkState != NETWORK_EMPTY) { | 660 if (m_networkState != NETWORK_EMPTY) { |
| 661 // 4.1 - Queue a task to fire a simple event named emptied at the media
element. |
| 662 scheduleEvent(EventTypeNames::emptied); |
| 663 |
| 664 // 4.2 - If a fetching process is in progress for the media element, the
user agent should stop it. |
661 m_networkState = NETWORK_EMPTY; | 665 m_networkState = NETWORK_EMPTY; |
| 666 |
| 667 // 4.3 - Forget the media element's media-resource-specific tracks. |
| 668 forgetResourceSpecificTracks(); |
| 669 |
| 670 // 4.4 - If readyState is not set to HAVE_NOTHING, then set it to that s
tate. |
662 m_readyState = HAVE_NOTHING; | 671 m_readyState = HAVE_NOTHING; |
663 m_readyStateMaximum = HAVE_NOTHING; | 672 m_readyStateMaximum = HAVE_NOTHING; |
| 673 |
| 674 // 4.5 - If the paused attribute is false, then set it to true. |
| 675 m_paused = true; |
| 676 |
| 677 // 4.6 - If seeking is true, set it to false. |
| 678 m_seeking = false; |
| 679 |
| 680 // 4.7 - Set the current playback position to 0. |
| 681 // Set the official playback position to 0. |
| 682 // If this changed the official playback position, then queue a ta
sk to fire a simple event named timeupdate at the media element. |
| 683 // FIXME: Add support for firing this event. |
| 684 |
| 685 // 4.8 - Set the initial playback position to 0. |
| 686 // FIXME: Make this less subtle. The position only becomes 0 because of
the createMediaPlayer() call |
| 687 // above. |
664 refreshCachedTime(); | 688 refreshCachedTime(); |
665 m_paused = true; | |
666 m_seeking = false; | |
667 invalidateCachedTime(); | 689 invalidateCachedTime(); |
668 scheduleEvent(EventTypeNames::emptied); | 690 |
| 691 // 4.9 - Set the timeline offset to Not-a-Number (NaN). |
| 692 // 4.10 - Update the duration attribute to Not-a-Number (NaN). |
| 693 |
| 694 |
669 updateMediaController(); | 695 updateMediaController(); |
670 if (RuntimeEnabledFeatures::videoTrackEnabled()) | 696 if (RuntimeEnabledFeatures::videoTrackEnabled()) |
671 updateActiveTextTrackCues(0); | 697 updateActiveTextTrackCues(0); |
672 } | 698 } |
673 | 699 |
674 // 5 - Set the playbackRate attribute to the value of the defaultPlaybackRat
e attribute. | 700 // 5 - Set the playbackRate attribute to the value of the defaultPlaybackRat
e attribute. |
675 setPlaybackRate(defaultPlaybackRate()); | 701 setPlaybackRate(defaultPlaybackRate()); |
676 | 702 |
677 // 6 - Set the error attribute to null and the autoplaying flag to true. | 703 // 6 - Set the error attribute to null and the autoplaying flag to true. |
678 m_error = nullptr; | 704 m_error = nullptr; |
679 m_autoplaying = true; | 705 m_autoplaying = true; |
680 | 706 |
681 // 7 - Invoke the media element's resource selection algorithm. | 707 // 7 - Invoke the media element's resource selection algorithm. |
682 | 708 |
683 // 8 - Note: Playback of any previously playing media resource for this elem
ent stops. | 709 // 8 - Note: Playback of any previously playing media resource for this elem
ent stops. |
684 | 710 |
685 // The resource selection algorithm | 711 // The resource selection algorithm |
686 // 1 - Set the networkState to NETWORK_NO_SOURCE | 712 // 1 - Set the networkState to NETWORK_NO_SOURCE |
687 m_networkState = NETWORK_NO_SOURCE; | 713 m_networkState = NETWORK_NO_SOURCE; |
688 | 714 |
689 // 2 - Asynchronously await a stable state. | 715 // 2 - Asynchronously await a stable state. |
690 | 716 |
691 m_playedTimeRanges = TimeRanges::create(); | 717 m_playedTimeRanges = TimeRanges::create(); |
| 718 |
| 719 // FIXME: Investigate whether these can be moved into m_networkState != NETW
ORK_EMPTY block above |
| 720 // so they are closer to the relevant spec steps. |
692 m_lastSeekTime = 0; | 721 m_lastSeekTime = 0; |
693 m_duration = numeric_limits<double>::quiet_NaN(); | 722 m_duration = numeric_limits<double>::quiet_NaN(); |
694 | 723 |
695 // The spec doesn't say to block the load event until we actually run the as
ynchronous section | 724 // The spec doesn't say to block the load event until we actually run the as
ynchronous section |
696 // algorithm, but do it now because we won't start that until after the time
r fires and the | 725 // algorithm, but do it now because we won't start that until after the time
r fires and the |
697 // event may have already fired by then. | 726 // event may have already fired by then. |
698 setShouldDelayLoadEvent(true); | 727 setShouldDelayLoadEvent(true); |
699 | 728 |
700 configureMediaControls(); | 729 configureMediaControls(); |
701 } | 730 } |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1352 | 1381 |
1353 // 4.8.10.5 | 1382 // 4.8.10.5 |
1354 // 6 - Reaching this step indicates that the media resource failed to load o
r that the given | 1383 // 6 - Reaching this step indicates that the media resource failed to load o
r that the given |
1355 // URL could not be resolved. In one atomic operation, run the following ste
ps: | 1384 // URL could not be resolved. In one atomic operation, run the following ste
ps: |
1356 | 1385 |
1357 // 6.1 - Set the error attribute to a new MediaError object whose code attri
bute is set to | 1386 // 6.1 - Set the error attribute to a new MediaError object whose code attri
bute is set to |
1358 // MEDIA_ERR_SRC_NOT_SUPPORTED. | 1387 // MEDIA_ERR_SRC_NOT_SUPPORTED. |
1359 m_error = MediaError::create(MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED); | 1388 m_error = MediaError::create(MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED); |
1360 | 1389 |
1361 // 6.2 - Forget the media element's media-resource-specific text tracks. | 1390 // 6.2 - Forget the media element's media-resource-specific text tracks. |
| 1391 forgetResourceSpecificTracks(); |
1362 | 1392 |
1363 // 6.3 - Set the element's networkState attribute to the NETWORK_NO_SOURCE v
alue. | 1393 // 6.3 - Set the element's networkState attribute to the NETWORK_NO_SOURCE v
alue. |
1364 m_networkState = NETWORK_NO_SOURCE; | 1394 m_networkState = NETWORK_NO_SOURCE; |
1365 | 1395 |
1366 // 7 - Queue a task to fire a simple event named error at the media element. | 1396 // 7 - Queue a task to fire a simple event named error at the media element. |
1367 scheduleEvent(EventTypeNames::error); | 1397 scheduleEvent(EventTypeNames::error); |
1368 | 1398 |
1369 closeMediaSource(); | 1399 closeMediaSource(); |
1370 | 1400 |
1371 // 8 - Set the element's delaying-the-load-event flag to false. This stops d
elaying the load event. | 1401 // 8 - Set the element's delaying-the-load-event flag to false. This stops d
elaying the load event. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 } | 1456 } |
1427 | 1457 |
1428 void HTMLMediaElement::mediaLoadingFailed(MediaPlayer::NetworkState error) | 1458 void HTMLMediaElement::mediaLoadingFailed(MediaPlayer::NetworkState error) |
1429 { | 1459 { |
1430 stopPeriodicTimers(); | 1460 stopPeriodicTimers(); |
1431 | 1461 |
1432 // If we failed while trying to load a <source> element, the movie was never
parsed, and there are more | 1462 // If we failed while trying to load a <source> element, the movie was never
parsed, and there are more |
1433 // <source> children, schedule the next one | 1463 // <source> children, schedule the next one |
1434 if (m_readyState < HAVE_METADATA && m_loadState == LoadingFromSourceElement)
{ | 1464 if (m_readyState < HAVE_METADATA && m_loadState == LoadingFromSourceElement)
{ |
1435 | 1465 |
| 1466 // resource selection algorithm |
| 1467 // Step 9.Otherwise.9 - Failed with elements: Queue a task, using the DO
M manipulation task source, to fire a simple event named error at the candidate
element. |
1436 if (m_currentSourceNode) | 1468 if (m_currentSourceNode) |
1437 m_currentSourceNode->scheduleErrorEvent(); | 1469 m_currentSourceNode->scheduleErrorEvent(); |
1438 else | 1470 else |
1439 WTF_LOG(Media, "HTMLMediaElement::setNetworkState - error event not
sent, <source> was removed"); | 1471 WTF_LOG(Media, "HTMLMediaElement::setNetworkState - error event not
sent, <source> was removed"); |
1440 | 1472 |
| 1473 // 9.Otherwise.10 - Asynchronously await a stable state. The synchronous
section consists of all the remaining steps of this algorithm until the algorit
hm says the synchronous section has ended. |
| 1474 |
| 1475 // 9.Otherwise.11 - Forget the media element's media-resource-specific t
racks. |
| 1476 forgetResourceSpecificTracks(); |
| 1477 |
1441 if (havePotentialSourceChild()) { | 1478 if (havePotentialSourceChild()) { |
1442 WTF_LOG(Media, "HTMLMediaElement::setNetworkState - scheduling next
<source>"); | 1479 WTF_LOG(Media, "HTMLMediaElement::setNetworkState - scheduling next
<source>"); |
1443 scheduleNextSourceChild(); | 1480 scheduleNextSourceChild(); |
1444 } else { | 1481 } else { |
1445 WTF_LOG(Media, "HTMLMediaElement::setNetworkState - no more <source>
elements, waiting"); | 1482 WTF_LOG(Media, "HTMLMediaElement::setNetworkState - no more <source>
elements, waiting"); |
1446 waitForSourceChange(); | 1483 waitForSourceChange(); |
1447 } | 1484 } |
1448 | 1485 |
1449 return; | 1486 return; |
1450 } | 1487 } |
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2508 void HTMLMediaElement::addTextTrack(TextTrack* track) | 2545 void HTMLMediaElement::addTextTrack(TextTrack* track) |
2509 { | 2546 { |
2510 textTracks()->append(track); | 2547 textTracks()->append(track); |
2511 | 2548 |
2512 closeCaptionTracksChanged(); | 2549 closeCaptionTracksChanged(); |
2513 } | 2550 } |
2514 | 2551 |
2515 void HTMLMediaElement::removeTextTrack(TextTrack* track) | 2552 void HTMLMediaElement::removeTextTrack(TextTrack* track) |
2516 { | 2553 { |
2517 TrackDisplayUpdateScope scope(this); | 2554 TrackDisplayUpdateScope scope(this); |
2518 TextTrackCueList* cues = track->cues(); | |
2519 if (cues) | |
2520 textTrackRemoveCues(track, cues); | |
2521 m_textTracks->remove(track); | 2555 m_textTracks->remove(track); |
2522 | 2556 |
2523 closeCaptionTracksChanged(); | 2557 closeCaptionTracksChanged(); |
2524 } | 2558 } |
2525 | 2559 |
2526 void HTMLMediaElement::removeAllInbandTracks() | 2560 void HTMLMediaElement::forgetResourceSpecificTracks() |
2527 { | 2561 { |
2528 if (!m_textTracks) | 2562 if (m_textTracks) { |
2529 return; | 2563 TrackDisplayUpdateScope scope(this); |
2530 | 2564 m_textTracks->removeAllInbandTracks(); |
2531 TrackDisplayUpdateScope scope(this); | 2565 closeCaptionTracksChanged(); |
2532 for (int i = m_textTracks->length() - 1; i >= 0; --i) { | |
2533 TextTrack* track = m_textTracks->item(i); | |
2534 | |
2535 if (track->trackType() == TextTrack::InBand) | |
2536 removeTextTrack(track); | |
2537 } | 2566 } |
2538 } | 2567 } |
2539 | 2568 |
2540 PassRefPtr<TextTrack> HTMLMediaElement::addTextTrack(const AtomicString& kind, c
onst AtomicString& label, const AtomicString& language, ExceptionState& exceptio
nState) | 2569 PassRefPtr<TextTrack> HTMLMediaElement::addTextTrack(const AtomicString& kind, c
onst AtomicString& label, const AtomicString& language, ExceptionState& exceptio
nState) |
2541 { | 2570 { |
2542 ASSERT(RuntimeEnabledFeatures::videoTrackEnabled()); | 2571 ASSERT(RuntimeEnabledFeatures::videoTrackEnabled()); |
2543 | 2572 |
2544 // 4.8.10.12.4 Text track API | 2573 // 4.8.10.12.4 Text track API |
2545 // The addTextTrack(kind, label, language) method of media elements, when in
voked, must run the following steps: | 2574 // The addTextTrack(kind, label, language) method of media elements, when in
voked, must run the following steps: |
2546 | 2575 |
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3382 m_player.clear(); | 3411 m_player.clear(); |
3383 | 3412 |
3384 #if ENABLE(WEB_AUDIO) | 3413 #if ENABLE(WEB_AUDIO) |
3385 if (m_audioSourceNode) | 3414 if (m_audioSourceNode) |
3386 m_audioSourceNode->unlock(); | 3415 m_audioSourceNode->unlock(); |
3387 #endif | 3416 #endif |
3388 } | 3417 } |
3389 | 3418 |
3390 void HTMLMediaElement::clearMediaPlayer(int flags) | 3419 void HTMLMediaElement::clearMediaPlayer(int flags) |
3391 { | 3420 { |
3392 removeAllInbandTracks(); | 3421 forgetResourceSpecificTracks(); |
3393 | 3422 |
3394 closeMediaSource(); | 3423 closeMediaSource(); |
3395 | 3424 |
3396 setMediaKeysInternal(0); | 3425 setMediaKeysInternal(0); |
3397 | 3426 |
3398 clearMediaPlayerAndAudioSourceProviderClient(); | 3427 clearMediaPlayerAndAudioSourceProviderClient(); |
3399 | 3428 |
3400 stopPeriodicTimers(); | 3429 stopPeriodicTimers(); |
3401 m_loadTimer.stop(); | 3430 m_loadTimer.stop(); |
3402 | 3431 |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3904 { | 3933 { |
3905 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); | 3934 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); |
3906 } | 3935 } |
3907 | 3936 |
3908 bool HTMLMediaElement::isInteractiveContent() const | 3937 bool HTMLMediaElement::isInteractiveContent() const |
3909 { | 3938 { |
3910 return fastHasAttribute(controlsAttr); | 3939 return fastHasAttribute(controlsAttr); |
3911 } | 3940 } |
3912 | 3941 |
3913 } | 3942 } |
OLD | NEW |