| 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 1688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1699 } | 1699 } |
| 1700 } | 1700 } |
| 1701 | 1701 |
| 1702 void HTMLMediaElement::changeNetworkStateFromLoadingToIdle() | 1702 void HTMLMediaElement::changeNetworkStateFromLoadingToIdle() |
| 1703 { | 1703 { |
| 1704 ASSERT(m_player); | 1704 ASSERT(m_player); |
| 1705 m_progressEventTimer.stop(); | 1705 m_progressEventTimer.stop(); |
| 1706 | 1706 |
| 1707 // Schedule one last progress event so we guarantee that at least one is fir
ed | 1707 // Schedule one last progress event so we guarantee that at least one is fir
ed |
| 1708 // for files that load very quickly. | 1708 // for files that load very quickly. |
| 1709 if (m_player->didLoadingProgress()) | 1709 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress()) |
| 1710 scheduleEvent(EventTypeNames::progress); | 1710 scheduleEvent(EventTypeNames::progress); |
| 1711 scheduleEvent(EventTypeNames::suspend); | 1711 scheduleEvent(EventTypeNames::suspend); |
| 1712 m_networkState = NETWORK_IDLE; | 1712 m_networkState = NETWORK_IDLE; |
| 1713 } | 1713 } |
| 1714 | 1714 |
| 1715 void HTMLMediaElement::mediaPlayerReadyStateChanged() | 1715 void HTMLMediaElement::mediaPlayerReadyStateChanged() |
| 1716 { | 1716 { |
| 1717 setReadyState(static_cast<ReadyState>(webMediaPlayer()->readyState())); | 1717 setReadyState(static_cast<ReadyState>(webMediaPlayer()->readyState())); |
| 1718 } | 1718 } |
| 1719 | 1719 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1838 | 1838 |
| 1839 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) | 1839 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) |
| 1840 { | 1840 { |
| 1841 ASSERT(m_player); | 1841 ASSERT(m_player); |
| 1842 if (m_networkState != NETWORK_LOADING) | 1842 if (m_networkState != NETWORK_LOADING) |
| 1843 return; | 1843 return; |
| 1844 | 1844 |
| 1845 double time = WTF::currentTime(); | 1845 double time = WTF::currentTime(); |
| 1846 double timedelta = time - m_previousProgressTime; | 1846 double timedelta = time - m_previousProgressTime; |
| 1847 | 1847 |
| 1848 if (m_player->didLoadingProgress()) { | 1848 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress()) { |
| 1849 scheduleEvent(EventTypeNames::progress); | 1849 scheduleEvent(EventTypeNames::progress); |
| 1850 m_previousProgressTime = time; | 1850 m_previousProgressTime = time; |
| 1851 m_sentStalledEvent = false; | 1851 m_sentStalledEvent = false; |
| 1852 if (renderer()) | 1852 if (renderer()) |
| 1853 renderer()->updateFromElement(); | 1853 renderer()->updateFromElement(); |
| 1854 } else if (timedelta > 3.0 && !m_sentStalledEvent) { | 1854 } else if (timedelta > 3.0 && !m_sentStalledEvent) { |
| 1855 scheduleEvent(EventTypeNames::stalled); | 1855 scheduleEvent(EventTypeNames::stalled); |
| 1856 m_sentStalledEvent = true; | 1856 m_sentStalledEvent = true; |
| 1857 setShouldDelayLoadEvent(false); | 1857 setShouldDelayLoadEvent(false); |
| 1858 } | 1858 } |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2127 } | 2127 } |
| 2128 | 2128 |
| 2129 HTMLMediaElement::DirectionOfPlayback HTMLMediaElement::directionOfPlayback() co
nst | 2129 HTMLMediaElement::DirectionOfPlayback HTMLMediaElement::directionOfPlayback() co
nst |
| 2130 { | 2130 { |
| 2131 return m_playbackRate >= 0 ? Forward : Backward; | 2131 return m_playbackRate >= 0 ? Forward : Backward; |
| 2132 } | 2132 } |
| 2133 | 2133 |
| 2134 void HTMLMediaElement::updatePlaybackRate() | 2134 void HTMLMediaElement::updatePlaybackRate() |
| 2135 { | 2135 { |
| 2136 double effectiveRate = effectivePlaybackRate(); | 2136 double effectiveRate = effectivePlaybackRate(); |
| 2137 if (m_player && potentiallyPlaying() && m_player->rate() != effectiveRate) | 2137 if (m_player && potentiallyPlaying()) |
| 2138 m_player->setRate(effectiveRate); | 2138 webMediaPlayer()->setRate(effectiveRate); |
| 2139 } | 2139 } |
| 2140 | 2140 |
| 2141 bool HTMLMediaElement::ended() const | 2141 bool HTMLMediaElement::ended() const |
| 2142 { | 2142 { |
| 2143 // 4.8.10.8 Playing the media resource | 2143 // 4.8.10.8 Playing the media resource |
| 2144 // The ended attribute must return true if the media element has ended | 2144 // The ended attribute must return true if the media element has ended |
| 2145 // playback and the direction of playback is forwards, and false otherwise. | 2145 // playback and the direction of playback is forwards, and false otherwise. |
| 2146 return endedPlayback() && directionOfPlayback() == Forward; | 2146 return endedPlayback() && directionOfPlayback() == Forward; |
| 2147 } | 2147 } |
| 2148 | 2148 |
| (...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3145 ASSERT(hasVideo()); // "resize" makes no sense absent video. | 3145 ASSERT(hasVideo()); // "resize" makes no sense absent video. |
| 3146 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement(*this)) | 3146 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement(*this)) |
| 3147 scheduleEvent(EventTypeNames::resize); | 3147 scheduleEvent(EventTypeNames::resize); |
| 3148 | 3148 |
| 3149 if (renderer()) | 3149 if (renderer()) |
| 3150 renderer()->updateFromElement(); | 3150 renderer()->updateFromElement(); |
| 3151 } | 3151 } |
| 3152 | 3152 |
| 3153 PassRefPtr<TimeRanges> HTMLMediaElement::buffered() const | 3153 PassRefPtr<TimeRanges> HTMLMediaElement::buffered() const |
| 3154 { | 3154 { |
| 3155 if (!m_player) | |
| 3156 return TimeRanges::create(); | |
| 3157 | |
| 3158 if (m_mediaSource) | 3155 if (m_mediaSource) |
| 3159 return m_mediaSource->buffered(); | 3156 return m_mediaSource->buffered(); |
| 3160 | 3157 |
| 3161 return m_player->buffered(); | 3158 if (!webMediaPlayer()) |
| 3159 return TimeRanges::create(); |
| 3160 |
| 3161 return TimeRanges::create(webMediaPlayer()->buffered()); |
| 3162 } | 3162 } |
| 3163 | 3163 |
| 3164 PassRefPtr<TimeRanges> HTMLMediaElement::played() | 3164 PassRefPtr<TimeRanges> HTMLMediaElement::played() |
| 3165 { | 3165 { |
| 3166 if (m_playing) { | 3166 if (m_playing) { |
| 3167 double time = currentTime(); | 3167 double time = currentTime(); |
| 3168 if (time > m_lastSeekTime) | 3168 if (time > m_lastSeekTime) |
| 3169 addPlayedRange(m_lastSeekTime, time); | 3169 addPlayedRange(m_lastSeekTime, time); |
| 3170 } | 3170 } |
| 3171 | 3171 |
| 3172 if (!m_playedTimeRanges) | 3172 if (!m_playedTimeRanges) |
| 3173 m_playedTimeRanges = TimeRanges::create(); | 3173 m_playedTimeRanges = TimeRanges::create(); |
| 3174 | 3174 |
| 3175 return m_playedTimeRanges->copy(); | 3175 return m_playedTimeRanges->copy(); |
| 3176 } | 3176 } |
| 3177 | 3177 |
| 3178 PassRefPtr<TimeRanges> HTMLMediaElement::seekable() const | 3178 PassRefPtr<TimeRanges> HTMLMediaElement::seekable() const |
| 3179 { | 3179 { |
| 3180 if (m_player) { | 3180 if (webMediaPlayer()) { |
| 3181 double maxTimeSeekable = m_player->maxTimeSeekable(); | 3181 double maxTimeSeekable = webMediaPlayer()->maxTimeSeekable(); |
| 3182 if (maxTimeSeekable) | 3182 if (maxTimeSeekable) |
| 3183 return TimeRanges::create(0, maxTimeSeekable); | 3183 return TimeRanges::create(0, maxTimeSeekable); |
| 3184 } | 3184 } |
| 3185 return TimeRanges::create(); | 3185 return TimeRanges::create(); |
| 3186 } | 3186 } |
| 3187 | 3187 |
| 3188 bool HTMLMediaElement::potentiallyPlaying() const | 3188 bool HTMLMediaElement::potentiallyPlaying() const |
| 3189 { | 3189 { |
| 3190 // "pausedToBuffer" means the media engine's rate is 0, but only because it
had to stop playing | 3190 // "pausedToBuffer" means the media engine's rate is 0, but only because it
had to stop playing |
| 3191 // when it ran out of buffered data. A movie is this state is "potentially p
laying", modulo the | 3191 // when it ran out of buffered data. A movie is this state is "potentially p
laying", modulo the |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3279 WTF_LOG(Media, "HTMLMediaElement::updatePlayState - shouldBePlaying = %s, pl
ayerPaused = %s", | 3279 WTF_LOG(Media, "HTMLMediaElement::updatePlayState - shouldBePlaying = %s, pl
ayerPaused = %s", |
| 3280 boolString(shouldBePlaying), boolString(playerPaused)); | 3280 boolString(shouldBePlaying), boolString(playerPaused)); |
| 3281 | 3281 |
| 3282 if (shouldBePlaying) { | 3282 if (shouldBePlaying) { |
| 3283 setDisplayMode(Video); | 3283 setDisplayMode(Video); |
| 3284 invalidateCachedTime(); | 3284 invalidateCachedTime(); |
| 3285 | 3285 |
| 3286 if (playerPaused) { | 3286 if (playerPaused) { |
| 3287 // Set rate, muted before calling play in case they were set before
the media engine was setup. | 3287 // Set rate, muted before calling play in case they were set before
the media engine was setup. |
| 3288 // The media engine should just stash the rate and muted values sinc
e it isn't already playing. | 3288 // The media engine should just stash the rate and muted values sinc
e it isn't already playing. |
| 3289 m_player->setRate(effectivePlaybackRate()); | 3289 webMediaPlayer()->setRate(effectivePlaybackRate()); |
| 3290 updateVolume(); | 3290 updateVolume(); |
| 3291 | 3291 |
| 3292 m_player->play(); | 3292 m_player->play(); |
| 3293 } | 3293 } |
| 3294 | 3294 |
| 3295 if (hasMediaControls()) | 3295 if (hasMediaControls()) |
| 3296 mediaControls()->playbackStarted(); | 3296 mediaControls()->playbackStarted(); |
| 3297 startPlaybackProgressTimer(); | 3297 startPlaybackProgressTimer(); |
| 3298 m_playing = true; | 3298 m_playing = true; |
| 3299 | 3299 |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3961 | 3961 |
| 3962 #if ENABLE(WEB_AUDIO) | 3962 #if ENABLE(WEB_AUDIO) |
| 3963 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 3963 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
| 3964 { | 3964 { |
| 3965 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) | 3965 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) |
| 3966 audioSourceProvider()->setClient(0); | 3966 audioSourceProvider()->setClient(0); |
| 3967 } | 3967 } |
| 3968 #endif | 3968 #endif |
| 3969 | 3969 |
| 3970 } | 3970 } |
| OLD | NEW |