| 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 2098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2109 void HTMLMediaElement::setPlaybackRate(double rate) | 2109 void HTMLMediaElement::setPlaybackRate(double rate) |
| 2110 { | 2110 { |
| 2111 WTF_LOG(Media, "HTMLMediaElement::setPlaybackRate(%f)", rate); | 2111 WTF_LOG(Media, "HTMLMediaElement::setPlaybackRate(%f)", rate); |
| 2112 | 2112 |
| 2113 if (m_playbackRate != rate) { | 2113 if (m_playbackRate != rate) { |
| 2114 m_playbackRate = rate; | 2114 m_playbackRate = rate; |
| 2115 invalidateCachedTime(); | 2115 invalidateCachedTime(); |
| 2116 scheduleEvent(EventTypeNames::ratechange); | 2116 scheduleEvent(EventTypeNames::ratechange); |
| 2117 } | 2117 } |
| 2118 | 2118 |
| 2119 if (m_player && potentiallyPlaying() && m_player->rate() != rate && !m_media
Controller) | 2119 updatePlaybackRate(); |
| 2120 m_player->setRate(rate); | 2120 } |
| 2121 |
| 2122 double HTMLMediaElement::effectivePlaybackRate() const |
| 2123 { |
| 2124 return m_mediaController ? m_mediaController->playbackRate() : m_playbackRat
e; |
| 2121 } | 2125 } |
| 2122 | 2126 |
| 2123 HTMLMediaElement::DirectionOfPlayback HTMLMediaElement::directionOfPlayback() co
nst | 2127 HTMLMediaElement::DirectionOfPlayback HTMLMediaElement::directionOfPlayback() co
nst |
| 2124 { | 2128 { |
| 2125 return m_playbackRate >= 0 ? Forward : Backward; | 2129 return m_playbackRate >= 0 ? Forward : Backward; |
| 2126 } | 2130 } |
| 2127 | 2131 |
| 2128 void HTMLMediaElement::updatePlaybackRate() | 2132 void HTMLMediaElement::updatePlaybackRate() |
| 2129 { | 2133 { |
| 2130 double effectiveRate = m_mediaController ? m_mediaController->playbackRate()
: m_playbackRate; | 2134 double effectiveRate = effectivePlaybackRate(); |
| 2131 if (m_player && potentiallyPlaying() && m_player->rate() != effectiveRate) | 2135 if (m_player && potentiallyPlaying() && m_player->rate() != effectiveRate) |
| 2132 m_player->setRate(effectiveRate); | 2136 m_player->setRate(effectiveRate); |
| 2133 } | 2137 } |
| 2134 | 2138 |
| 2135 bool HTMLMediaElement::ended() const | 2139 bool HTMLMediaElement::ended() const |
| 2136 { | 2140 { |
| 2137 // 4.8.10.8 Playing the media resource | 2141 // 4.8.10.8 Playing the media resource |
| 2138 // The ended attribute must return true if the media element has ended | 2142 // The ended attribute must return true if the media element has ended |
| 2139 // playback and the direction of playback is forwards, and false otherwise. | 2143 // playback and the direction of playback is forwards, and false otherwise. |
| 2140 return endedPlayback() && directionOfPlayback() == Forward; | 2144 return endedPlayback() && directionOfPlayback() == Forward; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2333 if (!m_mediaController && !m_paused) { | 2337 if (!m_mediaController && !m_paused) { |
| 2334 UseCounter::count(document(), UseCounter::HTMLMediaElementPauseAtFra
gmentEnd); | 2338 UseCounter::count(document(), UseCounter::HTMLMediaElementPauseAtFra
gmentEnd); |
| 2335 // changes paused to true and fires a simple event named pause at th
e media element. | 2339 // changes paused to true and fires a simple event named pause at th
e media element. |
| 2336 pause(); | 2340 pause(); |
| 2337 } | 2341 } |
| 2338 } | 2342 } |
| 2339 | 2343 |
| 2340 if (!m_seeking) | 2344 if (!m_seeking) |
| 2341 scheduleTimeupdateEvent(true); | 2345 scheduleTimeupdateEvent(true); |
| 2342 | 2346 |
| 2343 if (!m_playbackRate) | 2347 if (!effectivePlaybackRate()) |
| 2344 return; | 2348 return; |
| 2345 | 2349 |
| 2346 if (!m_paused && hasMediaControls()) | 2350 if (!m_paused && hasMediaControls()) |
| 2347 mediaControls()->playbackProgressed(); | 2351 mediaControls()->playbackProgressed(); |
| 2348 | 2352 |
| 2349 updateActiveTextTrackCues(currentTime()); | 2353 updateActiveTextTrackCues(currentTime()); |
| 2350 } | 2354 } |
| 2351 | 2355 |
| 2352 void HTMLMediaElement::scheduleTimeupdateEvent(bool periodicEvent) | 2356 void HTMLMediaElement::scheduleTimeupdateEvent(bool periodicEvent) |
| 2353 { | 2357 { |
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3268 WTF_LOG(Media, "HTMLMediaElement::updatePlayState - shouldBePlaying = %s, pl
ayerPaused = %s", | 3272 WTF_LOG(Media, "HTMLMediaElement::updatePlayState - shouldBePlaying = %s, pl
ayerPaused = %s", |
| 3269 boolString(shouldBePlaying), boolString(playerPaused)); | 3273 boolString(shouldBePlaying), boolString(playerPaused)); |
| 3270 | 3274 |
| 3271 if (shouldBePlaying) { | 3275 if (shouldBePlaying) { |
| 3272 setDisplayMode(Video); | 3276 setDisplayMode(Video); |
| 3273 invalidateCachedTime(); | 3277 invalidateCachedTime(); |
| 3274 | 3278 |
| 3275 if (playerPaused) { | 3279 if (playerPaused) { |
| 3276 // Set rate, muted before calling play in case they were set before
the media engine was setup. | 3280 // Set rate, muted before calling play in case they were set before
the media engine was setup. |
| 3277 // The media engine should just stash the rate and muted values sinc
e it isn't already playing. | 3281 // The media engine should just stash the rate and muted values sinc
e it isn't already playing. |
| 3278 m_player->setRate(m_playbackRate); | 3282 m_player->setRate(effectivePlaybackRate()); |
| 3279 updateVolume(); | 3283 updateVolume(); |
| 3280 | 3284 |
| 3281 m_player->play(); | 3285 m_player->play(); |
| 3282 } | 3286 } |
| 3283 | 3287 |
| 3284 if (hasMediaControls()) | 3288 if (hasMediaControls()) |
| 3285 mediaControls()->playbackStarted(); | 3289 mediaControls()->playbackStarted(); |
| 3286 startPlaybackProgressTimer(); | 3290 startPlaybackProgressTimer(); |
| 3287 m_playing = true; | 3291 m_playing = true; |
| 3288 | 3292 |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3950 | 3954 |
| 3951 #if ENABLE(WEB_AUDIO) | 3955 #if ENABLE(WEB_AUDIO) |
| 3952 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 3956 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
| 3953 { | 3957 { |
| 3954 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) | 3958 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) |
| 3955 audioSourceProvider()->setClient(0); | 3959 audioSourceProvider()->setClient(0); |
| 3956 } | 3960 } |
| 3957 #endif | 3961 #endif |
| 3958 | 3962 |
| 3959 } | 3963 } |
| OLD | NEW |