Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: Source/core/html/HTMLMediaElement.cpp

Issue 539103002: Seeking media fragment URI before loadeddata event (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@HAVE_NOTHING
Patch Set: renaming test and addressing comments Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 , m_lastTimeUpdateEventWallTime(0) 325 , m_lastTimeUpdateEventWallTime(0)
326 , m_lastTimeUpdateEventMovieTime(std::numeric_limits<double>::max()) 326 , m_lastTimeUpdateEventMovieTime(std::numeric_limits<double>::max())
327 , m_defaultPlaybackStartPosition(0) 327 , m_defaultPlaybackStartPosition(0)
328 , m_loadState(WaitingForSource) 328 , m_loadState(WaitingForSource)
329 , m_deferredLoadState(NotDeferred) 329 , m_deferredLoadState(NotDeferred)
330 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) 330 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired)
331 , m_webLayer(0) 331 , m_webLayer(0)
332 , m_preload(MediaPlayer::Auto) 332 , m_preload(MediaPlayer::Auto)
333 , m_displayMode(Unknown) 333 , m_displayMode(Unknown)
334 , m_cachedTime(MediaPlayer::invalidTime()) 334 , m_cachedTime(MediaPlayer::invalidTime())
335 , m_fragmentStartTime(MediaPlayer::invalidTime())
336 , m_fragmentEndTime(MediaPlayer::invalidTime()) 335 , m_fragmentEndTime(MediaPlayer::invalidTime())
337 , m_pendingActionFlags(0) 336 , m_pendingActionFlags(0)
338 , m_userGestureRequiredForPlay(false) 337 , m_userGestureRequiredForPlay(false)
339 , m_playing(false) 338 , m_playing(false)
340 , m_shouldDelayLoadEvent(false) 339 , m_shouldDelayLoadEvent(false)
341 , m_haveFiredLoadedData(false) 340 , m_haveFiredLoadedData(false)
342 , m_active(true) 341 , m_active(true)
343 , m_autoplaying(true) 342 , m_autoplaying(true)
344 , m_muted(false) 343 , m_muted(false)
345 , m_paused(true) 344 , m_paused(true)
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 if (wasPotentiallyPlaying && m_readyState < HAVE_FUTURE_DATA) { 1800 if (wasPotentiallyPlaying && m_readyState < HAVE_FUTURE_DATA) {
1802 // 4.8.10.8 1801 // 4.8.10.8
1803 scheduleTimeupdateEvent(false); 1802 scheduleTimeupdateEvent(false);
1804 scheduleEvent(EventTypeNames::waiting); 1803 scheduleEvent(EventTypeNames::waiting);
1805 } 1804 }
1806 } 1805 }
1807 1806
1808 if (m_readyState >= HAVE_METADATA && oldState < HAVE_METADATA) { 1807 if (m_readyState >= HAVE_METADATA && oldState < HAVE_METADATA) {
1809 createPlaceholderTracksIfNecessary(); 1808 createPlaceholderTracksIfNecessary();
1810 1809
1811 prepareMediaFragmentURI(); 1810 selectInitialTracksIfNecessary();
1812 1811
1813 selectInitialTracksIfNecessary(); 1812 MediaFragmentURIParser fragmentParser(m_currentSrc);
1813 m_fragmentEndTime = fragmentParser.endTime();
1814 1814
1815 m_duration = duration(); 1815 m_duration = duration();
1816 scheduleEvent(EventTypeNames::durationchange); 1816 scheduleEvent(EventTypeNames::durationchange);
1817 1817
1818 if (isHTMLVideoElement()) 1818 if (isHTMLVideoElement())
1819 scheduleEvent(EventTypeNames::resize); 1819 scheduleEvent(EventTypeNames::resize);
1820 scheduleEvent(EventTypeNames::loadedmetadata); 1820 scheduleEvent(EventTypeNames::loadedmetadata);
1821 1821
1822 if (m_defaultPlaybackStartPosition > 0) 1822 bool jumped = false;
1823 if (m_defaultPlaybackStartPosition > 0) {
1823 seek(m_defaultPlaybackStartPosition); 1824 seek(m_defaultPlaybackStartPosition);
1825 jumped = true;
1826 }
1827 m_defaultPlaybackStartPosition = 0;
1824 1828
1825 m_defaultPlaybackStartPosition = 0; 1829 double initialPlaybackPosition = fragmentParser.startTime();
1830 if (initialPlaybackPosition == MediaPlayer::invalidTime())
1831 initialPlaybackPosition = 0;
1832
1833 if (!jumped && initialPlaybackPosition > 0) {
1834 m_sentEndEvent = false;
1835 UseCounter::count(document(), UseCounter::HTMLMediaElementSeekToFrag mentStart);
1836 seek(initialPlaybackPosition);
1837 jumped = true;
1838 }
1839
1840 if (m_mediaController) {
1841 if (jumped && initialPlaybackPosition > m_mediaController->currentTi me())
1842 m_mediaController->setCurrentTime(initialPlaybackPosition);
1843 else
1844 seek(m_mediaController->currentTime());
1845 }
1846
1826 if (hasMediaControls()) 1847 if (hasMediaControls())
1827 mediaControls()->reset(); 1848 mediaControls()->reset();
1828 if (renderer()) 1849 if (renderer())
1829 renderer()->updateFromElement(); 1850 renderer()->updateFromElement();
1830 } 1851 }
1831 1852
1832 bool shouldUpdateDisplayState = false; 1853 bool shouldUpdateDisplayState = false;
1833 1854
1834 if (m_readyState >= HAVE_CURRENT_DATA && oldState < HAVE_CURRENT_DATA && !m_ haveFiredLoadedData) { 1855 if (m_readyState >= HAVE_CURRENT_DATA && oldState < HAVE_CURRENT_DATA && !m_ haveFiredLoadedData) {
1835 m_haveFiredLoadedData = true; 1856 m_haveFiredLoadedData = true;
1836 shouldUpdateDisplayState = true; 1857 shouldUpdateDisplayState = true;
1837 scheduleEvent(EventTypeNames::loadeddata); 1858 scheduleEvent(EventTypeNames::loadeddata);
1838 setShouldDelayLoadEvent(false); 1859 setShouldDelayLoadEvent(false);
1839 applyMediaFragmentURI();
1840 } 1860 }
1841 1861
1842 bool isPotentiallyPlaying = potentiallyPlaying(); 1862 bool isPotentiallyPlaying = potentiallyPlaying();
1843 if (m_readyState == HAVE_FUTURE_DATA && oldState <= HAVE_CURRENT_DATA && tra cksAreReady) { 1863 if (m_readyState == HAVE_FUTURE_DATA && oldState <= HAVE_CURRENT_DATA && tra cksAreReady) {
1844 scheduleEvent(EventTypeNames::canplay); 1864 scheduleEvent(EventTypeNames::canplay);
1845 if (isPotentiallyPlaying) 1865 if (isPotentiallyPlaying)
1846 scheduleEvent(EventTypeNames::playing); 1866 scheduleEvent(EventTypeNames::playing);
1847 shouldUpdateDisplayState = true; 1867 shouldUpdateDisplayState = true;
1848 } 1868 }
1849 1869
(...skipping 1994 matching lines...) Expand 10 before | Expand all | Expand 10 after
3844 // or if its media controller position is either before the media resource's earliest possible 3864 // or if its media controller position is either before the media resource's earliest possible
3845 // position relative to the MediaController's timeline or after the end of t he media resource 3865 // position relative to the MediaController's timeline or after the end of t he media resource
3846 // relative to the MediaController's timeline. 3866 // relative to the MediaController's timeline.
3847 double mediaControllerPosition = m_mediaController->currentTime(); 3867 double mediaControllerPosition = m_mediaController->currentTime();
3848 if (mediaControllerPosition < 0 || mediaControllerPosition > duration()) 3868 if (mediaControllerPosition < 0 || mediaControllerPosition > duration())
3849 return true; 3869 return true;
3850 3870
3851 return false; 3871 return false;
3852 } 3872 }
3853 3873
3854 void HTMLMediaElement::prepareMediaFragmentURI()
3855 {
3856 MediaFragmentURIParser fragmentParser(m_currentSrc);
3857 double dur = duration();
3858
3859 double start = fragmentParser.startTime();
3860 if (start != MediaFragmentURIParser::invalidTimeValue() && start > 0) {
3861 m_fragmentStartTime = start;
3862 if (m_fragmentStartTime > dur)
3863 m_fragmentStartTime = dur;
3864 } else
3865 m_fragmentStartTime = MediaPlayer::invalidTime();
3866
3867 double end = fragmentParser.endTime();
3868 if (end != MediaFragmentURIParser::invalidTimeValue() && end > 0 && end > m_ fragmentStartTime) {
3869 m_fragmentEndTime = end;
3870 if (m_fragmentEndTime > dur)
3871 m_fragmentEndTime = dur;
3872 } else
3873 m_fragmentEndTime = MediaPlayer::invalidTime();
3874
3875 // FIXME: Add support for selecting tracks by ID with the Media Fragments tr ack dimension.
3876
3877 if (m_fragmentStartTime != MediaPlayer::invalidTime() && m_readyState < HAVE _FUTURE_DATA)
3878 prepareToPlay();
3879 }
3880
3881 void HTMLMediaElement::applyMediaFragmentURI()
3882 {
3883 if (m_fragmentStartTime != MediaPlayer::invalidTime()) {
3884 m_sentEndEvent = false;
3885 UseCounter::count(document(), UseCounter::HTMLMediaElementSeekToFragment Start);
3886 seek(m_fragmentStartTime);
3887 }
3888 }
3889
3890 WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const 3874 WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const
3891 { 3875 {
3892 const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr); 3876 const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr);
3893 if (crossOriginMode.isNull()) 3877 if (crossOriginMode.isNull())
3894 return WebMediaPlayer::CORSModeUnspecified; 3878 return WebMediaPlayer::CORSModeUnspecified;
3895 if (equalIgnoringCase(crossOriginMode, "use-credentials")) 3879 if (equalIgnoringCase(crossOriginMode, "use-credentials"))
3896 return WebMediaPlayer::CORSModeUseCredentials; 3880 return WebMediaPlayer::CORSModeUseCredentials;
3897 return WebMediaPlayer::CORSModeAnonymous; 3881 return WebMediaPlayer::CORSModeAnonymous;
3898 } 3882 }
3899 3883
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
3983 3967
3984 #if ENABLE(WEB_AUDIO) 3968 #if ENABLE(WEB_AUDIO)
3985 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 3969 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
3986 { 3970 {
3987 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) 3971 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider())
3988 audioSourceProvider()->setClient(0); 3972 audioSourceProvider()->setClient(0);
3989 } 3973 }
3990 #endif 3974 #endif
3991 3975
3992 } 3976 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698