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