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 1816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1827 if (m_lastSeekTime < now) | 1827 if (m_lastSeekTime < now) |
1828 addPlayedRange(m_lastSeekTime, now); | 1828 addPlayedRange(m_lastSeekTime, now); |
1829 } | 1829 } |
1830 m_lastSeekTime = time; | 1830 m_lastSeekTime = time; |
1831 m_sentEndEvent = false; | 1831 m_sentEndEvent = false; |
1832 | 1832 |
1833 // 8 - Queue a task to fire a simple event named seeking at the element. | 1833 // 8 - Queue a task to fire a simple event named seeking at the element. |
1834 scheduleEvent(EventTypeNames::seeking); | 1834 scheduleEvent(EventTypeNames::seeking); |
1835 | 1835 |
1836 // 9 - Set the current playback position to the given new playback position | 1836 // 9 - Set the current playback position to the given new playback position |
1837 m_player->seek(time); | 1837 webMediaPlayer()->seek(time); |
1838 | 1838 |
1839 // 10-14 are handled, if necessary, when the engine signals a readystate cha
nge or otherwise | 1839 // 10-14 are handled, if necessary, when the engine signals a readystate cha
nge or otherwise |
1840 // satisfies seek completion and signals a time change. | 1840 // satisfies seek completion and signals a time change. |
1841 } | 1841 } |
1842 | 1842 |
1843 void HTMLMediaElement::finishSeek() | 1843 void HTMLMediaElement::finishSeek() |
1844 { | 1844 { |
1845 WTF_LOG(Media, "HTMLMediaElement::finishSeek"); | 1845 WTF_LOG(Media, "HTMLMediaElement::finishSeek"); |
1846 | 1846 |
1847 // 4.8.10.9 Seeking completion | 1847 // 4.8.10.9 Seeking completion |
(...skipping 19 matching lines...) Expand all Loading... |
1867 return webMediaPlayer() && webMediaPlayer()->hasAudio(); | 1867 return webMediaPlayer() && webMediaPlayer()->hasAudio(); |
1868 } | 1868 } |
1869 | 1869 |
1870 bool HTMLMediaElement::seeking() const | 1870 bool HTMLMediaElement::seeking() const |
1871 { | 1871 { |
1872 return m_seeking; | 1872 return m_seeking; |
1873 } | 1873 } |
1874 | 1874 |
1875 void HTMLMediaElement::refreshCachedTime() const | 1875 void HTMLMediaElement::refreshCachedTime() const |
1876 { | 1876 { |
1877 m_cachedTime = m_player->currentTime(); | 1877 if (!webMediaPlayer()) |
| 1878 return; |
| 1879 |
| 1880 m_cachedTime = webMediaPlayer()->currentTime(); |
1878 m_cachedTimeWallClockUpdateTime = WTF::currentTime(); | 1881 m_cachedTimeWallClockUpdateTime = WTF::currentTime(); |
1879 } | 1882 } |
1880 | 1883 |
1881 void HTMLMediaElement::invalidateCachedTime() | 1884 void HTMLMediaElement::invalidateCachedTime() |
1882 { | 1885 { |
1883 WTF_LOG(Media, "HTMLMediaElement::invalidateCachedTime"); | 1886 WTF_LOG(Media, "HTMLMediaElement::invalidateCachedTime"); |
1884 | 1887 |
1885 // Don't try to cache movie time when playback first starts as the time repo
rted by the engine | 1888 // Don't try to cache movie time when playback first starts as the time repo
rted by the engine |
1886 // sometimes fluctuates for a short amount of time, so the cached time will
be off if we take it | 1889 // sometimes fluctuates for a short amount of time, so the cached time will
be off if we take it |
1887 // too early. | 1890 // too early. |
1888 static const double minimumTimePlayingBeforeCacheSnapshot = 0.5; | 1891 static const double minimumTimePlayingBeforeCacheSnapshot = 0.5; |
1889 | 1892 |
1890 m_minimumWallClockTimeToCacheMediaTime = WTF::currentTime() + minimumTimePla
yingBeforeCacheSnapshot; | 1893 m_minimumWallClockTimeToCacheMediaTime = WTF::currentTime() + minimumTimePla
yingBeforeCacheSnapshot; |
1891 m_cachedTime = MediaPlayer::invalidTime(); | 1894 m_cachedTime = MediaPlayer::invalidTime(); |
1892 } | 1895 } |
1893 | 1896 |
1894 // playback state | 1897 // playback state |
1895 double HTMLMediaElement::currentTime() const | 1898 double HTMLMediaElement::currentTime() const |
1896 { | 1899 { |
1897 #if LOG_CACHED_TIME_WARNINGS | 1900 #if LOG_CACHED_TIME_WARNINGS |
1898 static const double minCachedDeltaForWarning = 0.01; | 1901 static const double minCachedDeltaForWarning = 0.01; |
1899 #endif | 1902 #endif |
1900 | 1903 |
1901 if (!m_player) | 1904 if (!m_player || !webMediaPlayer()) |
1902 return 0; | 1905 return 0; |
1903 | 1906 |
1904 if (m_seeking) { | 1907 if (m_seeking) { |
1905 WTF_LOG(Media, "HTMLMediaElement::currentTime - seeking, returning %f",
m_lastSeekTime); | 1908 WTF_LOG(Media, "HTMLMediaElement::currentTime - seeking, returning %f",
m_lastSeekTime); |
1906 return m_lastSeekTime; | 1909 return m_lastSeekTime; |
1907 } | 1910 } |
1908 | 1911 |
1909 if (m_cachedTime != MediaPlayer::invalidTime() && m_paused) { | 1912 if (m_cachedTime != MediaPlayer::invalidTime() && m_paused) { |
1910 #if LOG_CACHED_TIME_WARNINGS | 1913 #if LOG_CACHED_TIME_WARNINGS |
1911 double delta = m_cachedTime - m_player->currentTime(); | 1914 double delta = m_cachedTime - webMediaPlayer()->currentTime(); |
1912 if (delta > minCachedDeltaForWarning) | 1915 if (delta > minCachedDeltaForWarning) |
1913 WTF_LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time
is %f seconds off of media time when paused", delta); | 1916 WTF_LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time
is %f seconds off of media time when paused", delta); |
1914 #endif | 1917 #endif |
1915 return m_cachedTime; | 1918 return m_cachedTime; |
1916 } | 1919 } |
1917 | 1920 |
1918 refreshCachedTime(); | 1921 refreshCachedTime(); |
1919 | 1922 |
1920 return m_cachedTime; | 1923 return m_cachedTime; |
1921 } | 1924 } |
(...skipping 18 matching lines...) Expand all Loading... |
1940 // case because MediaSource and SourceBuffer do not notify the element | 1943 // case because MediaSource and SourceBuffer do not notify the element |
1941 // directly upon duration changes caused by endOfStream, remove, or append | 1944 // directly upon duration changes caused by endOfStream, remove, or append |
1942 // operations; rather the notification is triggered by the WebMediaPlayer | 1945 // operations; rather the notification is triggered by the WebMediaPlayer |
1943 // implementation observing that the underlying engine has updated duration | 1946 // implementation observing that the underlying engine has updated duration |
1944 // and notifying the element to consult its MediaSource for current | 1947 // and notifying the element to consult its MediaSource for current |
1945 // duration. See http://crbug.com/266644 | 1948 // duration. See http://crbug.com/266644 |
1946 | 1949 |
1947 if (m_mediaSource) | 1950 if (m_mediaSource) |
1948 return m_mediaSource->duration(); | 1951 return m_mediaSource->duration(); |
1949 | 1952 |
1950 return m_player->duration(); | 1953 return webMediaPlayer()->duration(); |
1951 } | 1954 } |
1952 | 1955 |
1953 bool HTMLMediaElement::paused() const | 1956 bool HTMLMediaElement::paused() const |
1954 { | 1957 { |
1955 return m_paused; | 1958 return m_paused; |
1956 } | 1959 } |
1957 | 1960 |
1958 double HTMLMediaElement::defaultPlaybackRate() const | 1961 double HTMLMediaElement::defaultPlaybackRate() const |
1959 { | 1962 { |
1960 return m_defaultPlaybackRate; | 1963 return m_defaultPlaybackRate; |
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2756 | 2759 |
2757 void HTMLMediaElement::mediaPlayerTimeChanged() | 2760 void HTMLMediaElement::mediaPlayerTimeChanged() |
2758 { | 2761 { |
2759 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged"); | 2762 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged"); |
2760 | 2763 |
2761 updateActiveTextTrackCues(currentTime()); | 2764 updateActiveTextTrackCues(currentTime()); |
2762 | 2765 |
2763 invalidateCachedTime(); | 2766 invalidateCachedTime(); |
2764 | 2767 |
2765 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t
he seek. | 2768 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t
he seek. |
2766 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !m_player->seeking()) | 2769 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see
king()) |
2767 finishSeek(); | 2770 finishSeek(); |
2768 | 2771 |
2769 // Always call scheduleTimeupdateEvent when the media engine reports a time
discontinuity, | 2772 // Always call scheduleTimeupdateEvent when the media engine reports a time
discontinuity, |
2770 // it will only queue a 'timeupdate' event if we haven't already posted one
at the current | 2773 // it will only queue a 'timeupdate' event if we haven't already posted one
at the current |
2771 // movie time. | 2774 // movie time. |
2772 scheduleTimeupdateEvent(false); | 2775 scheduleTimeupdateEvent(false); |
2773 | 2776 |
2774 double now = currentTime(); | 2777 double now = currentTime(); |
2775 double dur = duration(); | 2778 double dur = duration(); |
2776 | 2779 |
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3652 visitor->trace(m_error); | 3655 visitor->trace(m_error); |
3653 visitor->trace(m_currentSourceNode); | 3656 visitor->trace(m_currentSourceNode); |
3654 visitor->trace(m_nextChildNodeToConsider); | 3657 visitor->trace(m_nextChildNodeToConsider); |
3655 visitor->trace(m_textTracks); | 3658 visitor->trace(m_textTracks); |
3656 visitor->trace(m_textTracksWhenResourceSelectionBegan); | 3659 visitor->trace(m_textTracksWhenResourceSelectionBegan); |
3657 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); | 3660 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); |
3658 HTMLElement::trace(visitor); | 3661 HTMLElement::trace(visitor); |
3659 } | 3662 } |
3660 | 3663 |
3661 } | 3664 } |
OLD | NEW |