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 1848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1859 void HTMLMediaElement::addPlayedRange(double start, double end) | 1859 void HTMLMediaElement::addPlayedRange(double start, double end) |
1860 { | 1860 { |
1861 WTF_LOG(Media, "HTMLMediaElement::addPlayedRange(%f, %f)", start, end); | 1861 WTF_LOG(Media, "HTMLMediaElement::addPlayedRange(%f, %f)", start, end); |
1862 if (!m_playedTimeRanges) | 1862 if (!m_playedTimeRanges) |
1863 m_playedTimeRanges = TimeRanges::create(); | 1863 m_playedTimeRanges = TimeRanges::create(); |
1864 m_playedTimeRanges->add(start, end); | 1864 m_playedTimeRanges->add(start, end); |
1865 } | 1865 } |
1866 | 1866 |
1867 bool HTMLMediaElement::supportsSave() const | 1867 bool HTMLMediaElement::supportsSave() const |
1868 { | 1868 { |
1869 return m_player ? m_player->supportsSave() : false; | 1869 return webMediaPlayer() && webMediaPlayer()->supportsSave(); |
1870 } | 1870 } |
1871 | 1871 |
1872 void HTMLMediaElement::prepareToPlay() | 1872 void HTMLMediaElement::prepareToPlay() |
1873 { | 1873 { |
1874 WTF_LOG(Media, "HTMLMediaElement::prepareToPlay(%p)", this); | 1874 WTF_LOG(Media, "HTMLMediaElement::prepareToPlay(%p)", this); |
1875 if (m_havePreparedToPlay) | 1875 if (m_havePreparedToPlay) |
1876 return; | 1876 return; |
1877 m_havePreparedToPlay = true; | 1877 m_havePreparedToPlay = true; |
1878 | 1878 |
1879 if (loadIsDeferred()) | 1879 if (loadIsDeferred()) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1915 time = std::min(time, duration()); | 1915 time = std::min(time, duration()); |
1916 | 1916 |
1917 // 6 - If the new playback position is less than the earliest possible posit ion, let it be that position instead. | 1917 // 6 - If the new playback position is less than the earliest possible posit ion, let it be that position instead. |
1918 time = std::max(time, 0.0); | 1918 time = std::max(time, 0.0); |
1919 | 1919 |
1920 // Ask the media engine for the time value in the movie's time scale before comparing with current time. This | 1920 // Ask the media engine for the time value in the movie's time scale before comparing with current time. This |
1921 // is necessary because if the seek time is not equal to currentTime but the delta is less than the movie's | 1921 // is necessary because if the seek time is not equal to currentTime but the delta is less than the movie's |
1922 // time scale, we will ask the media engine to "seek" to the current movie t ime, which may be a noop and | 1922 // time scale, we will ask the media engine to "seek" to the current movie t ime, which may be a noop and |
1923 // not generate a timechanged callback. This means m_seeking will never be c leared and we will never | 1923 // not generate a timechanged callback. This means m_seeking will never be c leared and we will never |
1924 // fire a 'seeked' event. | 1924 // fire a 'seeked' event. |
1925 double mediaTime = webMediaPlayer()->mediaTimeForTimeValue(time); | |
1926 if (time != mediaTime) { | |
1925 #if !LOG_DISABLED | 1927 #if !LOG_DISABLED |
1926 double mediaTime = m_player->mediaTimeForTimeValue(time); | |
1927 if (time != mediaTime) | |
1928 WTF_LOG(Media, "HTMLMediaElement::seek(%f) - media timeline equivalent i s %f", time, mediaTime); | 1928 WTF_LOG(Media, "HTMLMediaElement::seek(%f) - media timeline equivalent i s %f", time, mediaTime); |
1929 #endif | 1929 #endif |
1930 time = m_player->mediaTimeForTimeValue(time); | 1930 time = mediaTime; |
1931 } | |
1931 | 1932 |
1932 // 7 - If the (possibly now changed) new playback position is not in one of the ranges given in the | 1933 // 7 - If the (possibly now changed) new playback position is not in one of the ranges given in the |
1933 // seekable attribute, then let it be the position in one of the ranges give n in the seekable attribute | 1934 // seekable attribute, then let it be the position in one of the ranges give n in the seekable attribute |
1934 // that is the nearest to the new playback position. ... If there are no ran ges given in the seekable | 1935 // that is the nearest to the new playback position. ... If there are no ran ges given in the seekable |
1935 // attribute then set the seeking IDL attribute to false and abort these ste ps. | 1936 // attribute then set the seeking IDL attribute to false and abort these ste ps. |
1936 RefPtr<TimeRanges> seekableRanges = seekable(); | 1937 RefPtr<TimeRanges> seekableRanges = seekable(); |
1937 | 1938 |
1938 // Short circuit seeking to the current time by just firing the events if no seek is required. | 1939 // Short circuit seeking to the current time by just firing the events if no seek is required. |
1939 // Don't skip calling the media engine if we are in poster mode because a se ek should always | 1940 // Don't skip calling the media engine if we are in poster mode because a se ek should always |
1940 // cancel poster display. | 1941 // cancel poster display. |
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3088 seek(duration, IGNORE_EXCEPTION); | 3089 seek(duration, IGNORE_EXCEPTION); |
3089 } | 3090 } |
3090 | 3091 |
3091 void HTMLMediaElement::mediaPlayerPlaybackStateChanged() | 3092 void HTMLMediaElement::mediaPlayerPlaybackStateChanged() |
3092 { | 3093 { |
3093 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged"); | 3094 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged"); |
3094 | 3095 |
3095 if (!m_player || m_pausedInternal) | 3096 if (!m_player || m_pausedInternal) |
3096 return; | 3097 return; |
3097 | 3098 |
3098 if (m_player->paused()) | 3099 if (webMediaPlayer()->paused()) |
3099 pause(); | 3100 pause(); |
3100 else | 3101 else |
3101 playInternal(); | 3102 playInternal(); |
3102 } | 3103 } |
3103 | 3104 |
3104 void HTMLMediaElement::mediaPlayerRequestFullscreen() | 3105 void HTMLMediaElement::mediaPlayerRequestFullscreen() |
3105 { | 3106 { |
3106 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerRequestFullscreen"); | 3107 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerRequestFullscreen"); |
3107 | 3108 |
3108 // The player is responsible for only invoking this callback in response to | 3109 // The player is responsible for only invoking this callback in response to |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3251 } | 3252 } |
3252 | 3253 |
3253 return shouldMute ? 0 : m_volume * volumeMultiplier; | 3254 return shouldMute ? 0 : m_volume * volumeMultiplier; |
3254 } | 3255 } |
3255 | 3256 |
3256 void HTMLMediaElement::updatePlayState() | 3257 void HTMLMediaElement::updatePlayState() |
3257 { | 3258 { |
3258 if (!m_player) | 3259 if (!m_player) |
3259 return; | 3260 return; |
3260 | 3261 |
3262 bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused(); | |
3261 if (m_pausedInternal) { | 3263 if (m_pausedInternal) { |
3262 if (!m_player->paused()) | 3264 if (isPlaying) |
3263 m_player->pause(); | 3265 webMediaPlayer()->pause(); |
3264 refreshCachedTime(); | 3266 refreshCachedTime(); |
3265 m_playbackProgressTimer.stop(); | 3267 m_playbackProgressTimer.stop(); |
3266 if (hasMediaControls()) | 3268 if (hasMediaControls()) |
3267 mediaControls()->playbackStopped(); | 3269 mediaControls()->playbackStopped(); |
3268 return; | 3270 return; |
3269 } | 3271 } |
3270 | 3272 |
3271 bool shouldBePlaying = potentiallyPlaying(); | 3273 bool shouldBePlaying = potentiallyPlaying(); |
3272 bool playerPaused = m_player->paused(); | |
3273 | 3274 |
3274 WTF_LOG(Media, "HTMLMediaElement::updatePlayState - shouldBePlaying = %s, pl ayerPaused = %s", | 3275 WTF_LOG(Media, "HTMLMediaElement::updatePlayState - shouldBePlaying = %s, pl ayerPaused = %s", |
acolwell GONE FROM CHROMIUM
2014/07/08 15:01:14
nit: These are just reflecting local variables so
Srirama
2014/07/08 16:47:27
Done.
| |
3275 boolString(shouldBePlaying), boolString(playerPaused)); | 3276 boolString(shouldBePlaying), boolString(!isPlaying)); |
3276 | 3277 |
3277 if (shouldBePlaying) { | 3278 if (shouldBePlaying) { |
3278 setDisplayMode(Video); | 3279 setDisplayMode(Video); |
3279 invalidateCachedTime(); | 3280 invalidateCachedTime(); |
3280 | 3281 |
3281 if (playerPaused) { | 3282 if (!isPlaying) { |
3282 // Set rate, muted before calling play in case they were set before the media engine was setup. | 3283 // Set rate, muted before calling play in case they were set before the media engine was setup. |
3283 // The media engine should just stash the rate and muted values sinc e it isn't already playing. | 3284 // The media engine should just stash the rate and muted values sinc e it isn't already playing. |
3284 webMediaPlayer()->setRate(effectivePlaybackRate()); | 3285 webMediaPlayer()->setRate(effectivePlaybackRate()); |
3285 updateVolume(); | 3286 updateVolume(); |
3286 | 3287 webMediaPlayer()->play(); |
3287 m_player->play(); | |
3288 } | 3288 } |
3289 | 3289 |
3290 if (hasMediaControls()) | 3290 if (hasMediaControls()) |
3291 mediaControls()->playbackStarted(); | 3291 mediaControls()->playbackStarted(); |
3292 startPlaybackProgressTimer(); | 3292 startPlaybackProgressTimer(); |
3293 m_playing = true; | 3293 m_playing = true; |
3294 | 3294 |
3295 } else { // Should not be playing right now | 3295 } else { // Should not be playing right now |
3296 if (!playerPaused) | 3296 if (isPlaying) |
3297 m_player->pause(); | 3297 webMediaPlayer()->pause(); |
3298 refreshCachedTime(); | 3298 refreshCachedTime(); |
3299 | 3299 |
3300 m_playbackProgressTimer.stop(); | 3300 m_playbackProgressTimer.stop(); |
3301 m_playing = false; | 3301 m_playing = false; |
3302 double time = currentTime(); | 3302 double time = currentTime(); |
3303 if (time > m_lastSeekTime) | 3303 if (time > m_lastSeekTime) |
3304 addPlayedRange(m_lastSeekTime, time); | 3304 addPlayedRange(m_lastSeekTime, time); |
3305 | 3305 |
3306 if (couldPlayIfEnoughData()) | 3306 if (couldPlayIfEnoughData()) |
3307 prepareToPlay(); | 3307 prepareToPlay(); |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3956 | 3956 |
3957 #if ENABLE(WEB_AUDIO) | 3957 #if ENABLE(WEB_AUDIO) |
3958 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 3958 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
3959 { | 3959 { |
3960 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) | 3960 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) |
3961 audioSourceProvider()->setClient(0); | 3961 audioSourceProvider()->setClient(0); |
3962 } | 3962 } |
3963 #endif | 3963 #endif |
3964 | 3964 |
3965 } | 3965 } |
OLD | NEW |