Chromium Code Reviews| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 #if !LOG_DISABLED | 1783 #if !LOG_DISABLED |
| 1784 double mediaTime = m_player->mediaTimeForTimeValue(time); | 1784 double mediaTime = webMediaPlayer() ? webMediaPlayer()->mediaTimeForTimeValu e(time) : time; |
|
philipj_slow
2014/05/27 20:54:56
This ends up looking a bit weird given the followi
| |
| 1785 if (time != mediaTime) | 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 if (webMediaPlayer()) |
| 1789 time = webMediaPlayer()->mediaTimeForTimeValue(time); | |
| 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 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2828 seek(duration, IGNORE_EXCEPTION); | 2829 seek(duration, IGNORE_EXCEPTION); |
| 2829 } | 2830 } |
| 2830 | 2831 |
| 2831 void HTMLMediaElement::mediaPlayerPlaybackStateChanged() | 2832 void HTMLMediaElement::mediaPlayerPlaybackStateChanged() |
| 2832 { | 2833 { |
| 2833 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged"); | 2834 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged"); |
| 2834 | 2835 |
| 2835 if (!m_player || m_pausedInternal) | 2836 if (!m_player || m_pausedInternal) |
| 2836 return; | 2837 return; |
| 2837 | 2838 |
| 2838 if (m_player->paused()) | 2839 if (webMediaPlayer() && webMediaPlayer()->paused()) |
| 2839 pause(); | 2840 pause(); |
| 2840 else | 2841 else |
| 2841 playInternal(); | 2842 playInternal(); |
| 2842 } | 2843 } |
| 2843 | 2844 |
| 2844 void HTMLMediaElement::mediaPlayerRequestFullscreen() | 2845 void HTMLMediaElement::mediaPlayerRequestFullscreen() |
| 2845 { | 2846 { |
| 2846 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerRequestFullscreen"); | 2847 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerRequestFullscreen"); |
| 2847 | 2848 |
| 2848 // The player is responsible for only invoking this callback in response to | 2849 // 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... | |
| 3000 | 3001 |
| 3001 return shouldMute ? 0 : m_volume * volumeMultiplier; | 3002 return shouldMute ? 0 : m_volume * volumeMultiplier; |
| 3002 } | 3003 } |
| 3003 | 3004 |
| 3004 void HTMLMediaElement::updatePlayState() | 3005 void HTMLMediaElement::updatePlayState() |
| 3005 { | 3006 { |
| 3006 if (!m_player) | 3007 if (!m_player) |
| 3007 return; | 3008 return; |
| 3008 | 3009 |
| 3009 if (m_pausedInternal) { | 3010 if (m_pausedInternal) { |
| 3010 if (!m_player->paused()) | 3011 if (webMediaPlayer() && !webMediaPlayer()->paused()) |
| 3011 m_player->pause(); | 3012 webMediaPlayer()->pause(); |
| 3012 refreshCachedTime(); | 3013 refreshCachedTime(); |
| 3013 m_playbackProgressTimer.stop(); | 3014 m_playbackProgressTimer.stop(); |
| 3014 if (hasMediaControls()) | 3015 if (hasMediaControls()) |
| 3015 mediaControls()->playbackStopped(); | 3016 mediaControls()->playbackStopped(); |
| 3016 return; | 3017 return; |
| 3017 } | 3018 } |
| 3018 | 3019 |
| 3019 bool shouldBePlaying = potentiallyPlaying(); | 3020 bool shouldBePlaying = potentiallyPlaying(); |
| 3020 bool playerPaused = m_player->paused(); | 3021 bool playerPaused = webMediaPlayer() && webMediaPlayer()->paused(); |
| 3021 | 3022 |
| 3022 WTF_LOG(Media, "HTMLMediaElement::updatePlayState - shouldBePlaying = %s, pl ayerPaused = %s", | 3023 WTF_LOG(Media, "HTMLMediaElement::updatePlayState - shouldBePlaying = %s, pl ayerPaused = %s", |
| 3023 boolString(shouldBePlaying), boolString(playerPaused)); | 3024 boolString(shouldBePlaying), boolString(playerPaused)); |
| 3024 | 3025 |
| 3025 if (shouldBePlaying) { | 3026 if (shouldBePlaying) { |
| 3026 setDisplayMode(Video); | 3027 setDisplayMode(Video); |
| 3027 invalidateCachedTime(); | 3028 invalidateCachedTime(); |
| 3028 | 3029 |
| 3029 if (playerPaused) { | 3030 if (playerPaused) { |
| 3030 // Set rate, muted before calling play in case they were set before the media engine was setup. | 3031 // Set rate, muted before calling play in case they were set before the media engine was setup. |
| 3031 // The media engine should just stash the rate and muted values sinc e it isn't already playing. | 3032 // The media engine should just stash the rate and muted values sinc e it isn't already playing. |
| 3032 m_player->setRate(m_playbackRate); | 3033 m_player->setRate(m_playbackRate); |
| 3033 updateVolume(); | 3034 updateVolume(); |
| 3034 | 3035 |
| 3035 m_player->play(); | 3036 if (webMediaPlayer()) |
| 3037 webMediaPlayer()->play(); | |
| 3036 } | 3038 } |
| 3037 | 3039 |
| 3038 if (hasMediaControls()) | 3040 if (hasMediaControls()) |
| 3039 mediaControls()->playbackStarted(); | 3041 mediaControls()->playbackStarted(); |
| 3040 startPlaybackProgressTimer(); | 3042 startPlaybackProgressTimer(); |
| 3041 m_playing = true; | 3043 m_playing = true; |
| 3042 | 3044 |
| 3043 } else { // Should not be playing right now | 3045 } else { // Should not be playing right now |
| 3044 if (!playerPaused) | 3046 if (!playerPaused && webMediaPlayer()) |
| 3045 m_player->pause(); | 3047 webMediaPlayer()->pause(); |
| 3046 refreshCachedTime(); | 3048 refreshCachedTime(); |
| 3047 | 3049 |
| 3048 m_playbackProgressTimer.stop(); | 3050 m_playbackProgressTimer.stop(); |
| 3049 m_playing = false; | 3051 m_playing = false; |
| 3050 double time = currentTime(); | 3052 double time = currentTime(); |
| 3051 if (time > m_lastSeekTime) | 3053 if (time > m_lastSeekTime) |
| 3052 addPlayedRange(m_lastSeekTime, time); | 3054 addPlayedRange(m_lastSeekTime, time); |
| 3053 | 3055 |
| 3054 if (couldPlayIfEnoughData()) | 3056 if (couldPlayIfEnoughData()) |
| 3055 prepareToPlay(); | 3057 prepareToPlay(); |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3654 visitor->trace(m_error); | 3656 visitor->trace(m_error); |
| 3655 visitor->trace(m_currentSourceNode); | 3657 visitor->trace(m_currentSourceNode); |
| 3656 visitor->trace(m_nextChildNodeToConsider); | 3658 visitor->trace(m_nextChildNodeToConsider); |
| 3657 visitor->trace(m_textTracks); | 3659 visitor->trace(m_textTracks); |
| 3658 visitor->trace(m_textTracksWhenResourceSelectionBegan); | 3660 visitor->trace(m_textTracksWhenResourceSelectionBegan); |
| 3659 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); | 3661 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); |
| 3660 HTMLElement::trace(visitor); | 3662 HTMLElement::trace(visitor); |
| 3661 } | 3663 } |
| 3662 | 3664 |
| 3663 } | 3665 } |
| OLD | NEW |