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 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1717 void HTMLMediaElement::addPlayedRange(double start, double end) | 1717 void HTMLMediaElement::addPlayedRange(double start, double end) |
1718 { | 1718 { |
1719 WTF_LOG(Media, "HTMLMediaElement::addPlayedRange(%f, %f)", start, end); | 1719 WTF_LOG(Media, "HTMLMediaElement::addPlayedRange(%f, %f)", start, end); |
1720 if (!m_playedTimeRanges) | 1720 if (!m_playedTimeRanges) |
1721 m_playedTimeRanges = TimeRanges::create(); | 1721 m_playedTimeRanges = TimeRanges::create(); |
1722 m_playedTimeRanges->add(start, end); | 1722 m_playedTimeRanges->add(start, end); |
1723 } | 1723 } |
1724 | 1724 |
1725 bool HTMLMediaElement::supportsSave() const | 1725 bool HTMLMediaElement::supportsSave() const |
1726 { | 1726 { |
1727 return m_player ? m_player->supportsSave() : false; | 1727 return webMediaPlayer() && webMediaPlayer()->supportsSave(); |
1728 } | 1728 } |
1729 | 1729 |
1730 void HTMLMediaElement::prepareToPlay() | 1730 void HTMLMediaElement::prepareToPlay() |
1731 { | 1731 { |
1732 WTF_LOG(Media, "HTMLMediaElement::prepareToPlay(%p)", this); | 1732 WTF_LOG(Media, "HTMLMediaElement::prepareToPlay(%p)", this); |
1733 if (m_havePreparedToPlay) | 1733 if (m_havePreparedToPlay) |
1734 return; | 1734 return; |
1735 m_havePreparedToPlay = true; | 1735 m_havePreparedToPlay = true; |
1736 | 1736 |
1737 if (m_delayingLoadForPreloadNone) | 1737 if (m_delayingLoadForPreloadNone) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1773 time = min(time, duration()); | 1773 time = min(time, duration()); |
1774 | 1774 |
1775 // 6 - If the new playback position is less than the earliest possible posit
ion, let it be that position instead. | 1775 // 6 - If the new playback position is less than the earliest possible posit
ion, let it be that position instead. |
1776 time = max(time, 0.0); | 1776 time = max(time, 0.0); |
1777 | 1777 |
1778 // Ask the media engine for the time value in the movie's time scale before
comparing with current time. This | 1778 // Ask the media engine for the time value in the movie's time scale before
comparing with current time. This |
1779 // is necessary because if the seek time is not equal to currentTime but the
delta is less than the movie's | 1779 // is necessary because if the seek time is not equal to currentTime but the
delta is less than the movie's |
1780 // time scale, we will ask the media engine to "seek" to the current movie t
ime, which may be a noop and | 1780 // time scale, we will ask the media engine to "seek" to the current movie t
ime, which may be a noop and |
1781 // not generate a timechanged callback. This means m_seeking will never be c
leared and we will never | 1781 // not generate a timechanged callback. This means m_seeking will never be c
leared and we will never |
1782 // fire a 'seeked' event. | 1782 // fire a 'seeked' event. |
| 1783 double mediaTime = webMediaPlayer()->mediaTimeForTimeValue(time); |
| 1784 if (time != mediaTime) { |
1783 #if !LOG_DISABLED | 1785 #if !LOG_DISABLED |
1784 double mediaTime = m_player->mediaTimeForTimeValue(time); | |
1785 if (time != mediaTime) | |
1786 WTF_LOG(Media, "HTMLMediaElement::seek(%f) - media timeline equivalent i
s %f", time, mediaTime); | 1786 WTF_LOG(Media, "HTMLMediaElement::seek(%f) - media timeline equivalent i
s %f", time, mediaTime); |
1787 #endif | 1787 #endif |
1788 time = m_player->mediaTimeForTimeValue(time); | 1788 time = mediaTime; |
| 1789 } |
1789 | 1790 |
1790 // 7 - If the (possibly now changed) new playback position is not in one of
the ranges given in the | 1791 // 7 - If the (possibly now changed) new playback position is not in one of
the ranges given in the |
1791 // seekable attribute, then let it be the position in one of the ranges give
n in the seekable attribute | 1792 // seekable attribute, then let it be the position in one of the ranges give
n in the seekable attribute |
1792 // that is the nearest to the new playback position. ... If there are no ran
ges given in the seekable | 1793 // that is the nearest to the new playback position. ... If there are no ran
ges given in the seekable |
1793 // attribute then set the seeking IDL attribute to false and abort these ste
ps. | 1794 // attribute then set the seeking IDL attribute to false and abort these ste
ps. |
1794 RefPtr<TimeRanges> seekableRanges = seekable(); | 1795 RefPtr<TimeRanges> seekableRanges = seekable(); |
1795 | 1796 |
1796 // Short circuit seeking to the current time by just firing the events if no
seek is required. | 1797 // Short circuit seeking to the current time by just firing the events if no
seek is required. |
1797 // Don't skip calling the media engine if we are in poster mode because a se
ek should always | 1798 // Don't skip calling the media engine if we are in poster mode because a se
ek should always |
1798 // cancel poster display. | 1799 // cancel poster display. |
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2823 seek(duration, IGNORE_EXCEPTION); | 2824 seek(duration, IGNORE_EXCEPTION); |
2824 } | 2825 } |
2825 | 2826 |
2826 void HTMLMediaElement::mediaPlayerPlaybackStateChanged() | 2827 void HTMLMediaElement::mediaPlayerPlaybackStateChanged() |
2827 { | 2828 { |
2828 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged"); | 2829 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged"); |
2829 | 2830 |
2830 if (!m_player || m_pausedInternal) | 2831 if (!m_player || m_pausedInternal) |
2831 return; | 2832 return; |
2832 | 2833 |
2833 if (m_player->paused()) | 2834 if (webMediaPlayer()->paused()) |
2834 pause(); | 2835 pause(); |
2835 else | 2836 else |
2836 playInternal(); | 2837 playInternal(); |
2837 } | 2838 } |
2838 | 2839 |
2839 void HTMLMediaElement::mediaPlayerRequestFullscreen() | 2840 void HTMLMediaElement::mediaPlayerRequestFullscreen() |
2840 { | 2841 { |
2841 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerRequestFullscreen"); | 2842 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerRequestFullscreen"); |
2842 | 2843 |
2843 // The player is responsible for only invoking this callback in response to | 2844 // The player is responsible for only invoking this callback in response to |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2995 | 2996 |
2996 return shouldMute ? 0 : m_volume * volumeMultiplier; | 2997 return shouldMute ? 0 : m_volume * volumeMultiplier; |
2997 } | 2998 } |
2998 | 2999 |
2999 void HTMLMediaElement::updatePlayState() | 3000 void HTMLMediaElement::updatePlayState() |
3000 { | 3001 { |
3001 if (!m_player) | 3002 if (!m_player) |
3002 return; | 3003 return; |
3003 | 3004 |
3004 if (m_pausedInternal) { | 3005 if (m_pausedInternal) { |
3005 if (!m_player->paused()) | 3006 if (webMediaPlayer() && !webMediaPlayer()->paused()) |
3006 m_player->pause(); | 3007 webMediaPlayer()->pause(); |
3007 refreshCachedTime(); | 3008 refreshCachedTime(); |
3008 m_playbackProgressTimer.stop(); | 3009 m_playbackProgressTimer.stop(); |
3009 if (hasMediaControls()) | 3010 if (hasMediaControls()) |
3010 mediaControls()->playbackStopped(); | 3011 mediaControls()->playbackStopped(); |
3011 return; | 3012 return; |
3012 } | 3013 } |
3013 | 3014 |
3014 bool shouldBePlaying = potentiallyPlaying(); | 3015 bool shouldBePlaying = potentiallyPlaying(); |
3015 bool playerPaused = m_player->paused(); | 3016 bool playerPaused = webMediaPlayer() && webMediaPlayer()->paused(); |
3016 | 3017 |
3017 WTF_LOG(Media, "HTMLMediaElement::updatePlayState - shouldBePlaying = %s, pl
ayerPaused = %s", | 3018 WTF_LOG(Media, "HTMLMediaElement::updatePlayState - shouldBePlaying = %s, pl
ayerPaused = %s", |
3018 boolString(shouldBePlaying), boolString(playerPaused)); | 3019 boolString(shouldBePlaying), boolString(playerPaused)); |
3019 | 3020 |
3020 if (shouldBePlaying) { | 3021 if (shouldBePlaying) { |
3021 setDisplayMode(Video); | 3022 setDisplayMode(Video); |
3022 invalidateCachedTime(); | 3023 invalidateCachedTime(); |
3023 | 3024 |
3024 if (playerPaused) { | 3025 if (playerPaused) { |
3025 // Set rate, muted before calling play in case they were set before
the media engine was setup. | 3026 // Set rate, muted before calling play in case they were set before
the media engine was setup. |
3026 // The media engine should just stash the rate and muted values sinc
e it isn't already playing. | 3027 // The media engine should just stash the rate and muted values sinc
e it isn't already playing. |
3027 m_player->setRate(m_playbackRate); | 3028 m_player->setRate(m_playbackRate); |
3028 updateVolume(); | 3029 updateVolume(); |
3029 | 3030 webMediaPlayer()->play(); |
3030 m_player->play(); | |
3031 } | 3031 } |
3032 | 3032 |
3033 if (hasMediaControls()) | 3033 if (hasMediaControls()) |
3034 mediaControls()->playbackStarted(); | 3034 mediaControls()->playbackStarted(); |
3035 startPlaybackProgressTimer(); | 3035 startPlaybackProgressTimer(); |
3036 m_playing = true; | 3036 m_playing = true; |
3037 | 3037 |
3038 } else { // Should not be playing right now | 3038 } else { // Should not be playing right now |
3039 if (!playerPaused) | 3039 if (!playerPaused && webMediaPlayer()) |
3040 m_player->pause(); | 3040 webMediaPlayer()->pause(); |
3041 refreshCachedTime(); | 3041 refreshCachedTime(); |
3042 | 3042 |
3043 m_playbackProgressTimer.stop(); | 3043 m_playbackProgressTimer.stop(); |
3044 m_playing = false; | 3044 m_playing = false; |
3045 double time = currentTime(); | 3045 double time = currentTime(); |
3046 if (time > m_lastSeekTime) | 3046 if (time > m_lastSeekTime) |
3047 addPlayedRange(m_lastSeekTime, time); | 3047 addPlayedRange(m_lastSeekTime, time); |
3048 | 3048 |
3049 if (couldPlayIfEnoughData()) | 3049 if (couldPlayIfEnoughData()) |
3050 prepareToPlay(); | 3050 prepareToPlay(); |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3649 visitor->trace(m_error); | 3649 visitor->trace(m_error); |
3650 visitor->trace(m_currentSourceNode); | 3650 visitor->trace(m_currentSourceNode); |
3651 visitor->trace(m_nextChildNodeToConsider); | 3651 visitor->trace(m_nextChildNodeToConsider); |
3652 visitor->trace(m_textTracks); | 3652 visitor->trace(m_textTracks); |
3653 visitor->trace(m_textTracksWhenResourceSelectionBegan); | 3653 visitor->trace(m_textTracksWhenResourceSelectionBegan); |
3654 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); | 3654 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); |
3655 HTMLElement::trace(visitor); | 3655 HTMLElement::trace(visitor); |
3656 } | 3656 } |
3657 | 3657 |
3658 } | 3658 } |
OLD | NEW |