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

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: Seeking media fragments if they have media controller 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
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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_cachedTimeWallClockUpdateTime(0) 335 , m_cachedTimeWallClockUpdateTime(0)
336 , m_minimumWallClockTimeToCacheMediaTime(0) 336 , m_minimumWallClockTimeToCacheMediaTime(0)
337 , m_fragmentStartTime(MediaPlayer::invalidTime())
338 , m_fragmentEndTime(MediaPlayer::invalidTime()) 337 , m_fragmentEndTime(MediaPlayer::invalidTime())
339 , m_pendingActionFlags(0) 338 , m_pendingActionFlags(0)
340 , m_userGestureRequiredForPlay(false) 339 , m_userGestureRequiredForPlay(false)
341 , m_playing(false) 340 , m_playing(false)
342 , m_shouldDelayLoadEvent(false) 341 , m_shouldDelayLoadEvent(false)
343 , m_haveFiredLoadedData(false) 342 , m_haveFiredLoadedData(false)
344 , m_active(true) 343 , m_active(true)
345 , m_autoplaying(true) 344 , m_autoplaying(true)
346 , m_muted(false) 345 , m_muted(false)
347 , m_paused(true) 346 , m_paused(true)
(...skipping 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after
1806 if (wasPotentiallyPlaying && m_readyState < HAVE_FUTURE_DATA) { 1805 if (wasPotentiallyPlaying && m_readyState < HAVE_FUTURE_DATA) {
1807 // 4.8.10.8 1806 // 4.8.10.8
1808 scheduleTimeupdateEvent(false); 1807 scheduleTimeupdateEvent(false);
1809 scheduleEvent(EventTypeNames::waiting); 1808 scheduleEvent(EventTypeNames::waiting);
1810 } 1809 }
1811 } 1810 }
1812 1811
1813 if (m_readyState >= HAVE_METADATA && oldState < HAVE_METADATA) { 1812 if (m_readyState >= HAVE_METADATA && oldState < HAVE_METADATA) {
1814 createPlaceholderTracksIfNecessary(); 1813 createPlaceholderTracksIfNecessary();
1815 1814
1816 prepareMediaFragmentURI(); 1815 selectInitialTracksIfNecessary();
1817 1816
1818 selectInitialTracksIfNecessary(); 1817 MediaFragmentURIParser fragmentParser(m_currentSrc);
1818 m_fragmentEndTime = fragmentParser.endTime();
1819 1819
1820 m_duration = duration(); 1820 m_duration = duration();
1821 scheduleEvent(EventTypeNames::durationchange); 1821 scheduleEvent(EventTypeNames::durationchange);
1822 1822
1823 if (isHTMLVideoElement()) 1823 if (isHTMLVideoElement())
1824 scheduleEvent(EventTypeNames::resize); 1824 scheduleEvent(EventTypeNames::resize);
1825 scheduleEvent(EventTypeNames::loadedmetadata); 1825 scheduleEvent(EventTypeNames::loadedmetadata);
1826 1826
1827 bool jumped = false;
1827 if (m_defaultPlaybackStartPosition > 0) { 1828 if (m_defaultPlaybackStartPosition > 0) {
1828 seek(m_defaultPlaybackStartPosition); 1829 seek(m_defaultPlaybackStartPosition);
1830 jumped = true;
1829 m_defaultPlaybackStartPosition = 0; 1831 m_defaultPlaybackStartPosition = 0;
1830 } 1832 }
1831 1833
1834 if (!jumped) {
1835 double start = fragmentParser.startTime();
1836 if (start != MediaPlayer::invalidTime() && start > 0) {
1837 m_sentEndEvent = false;
1838 UseCounter::count(document(), UseCounter::HTMLMediaElementSeekTo FragmentStart);
1839 seek(start);
1840 jumped = true;
1841 }
1842 // FIXME: Add support for selecting tracks by ID with the Media Frag ments track dimension.
1843 }
1844
1845 if (jumped && m_mediaController && m_mediaController->currentTime() < cu rrentTime())
philipj_slow 2014/09/10 12:25:48 This bit would be clearer if the initial playback
amogh.bihani 2014/09/11 13:35:59 I guess then it would be going away from media ele
philipj_slow 2014/09/11 14:38:26 Yes, AFAICT that step doesn't amount to anything t
amogh.bihani 2014/09/12 11:02:23 Yes sure :)
1846 m_mediaController->setCurrentTime(currentTime());
1847
1832 if (hasMediaControls()) 1848 if (hasMediaControls())
1833 mediaControls()->reset(); 1849 mediaControls()->reset();
1834 if (renderer()) 1850 if (renderer())
1835 renderer()->updateFromElement(); 1851 renderer()->updateFromElement();
1836 } 1852 }
1837 1853
1838 bool shouldUpdateDisplayState = false; 1854 bool shouldUpdateDisplayState = false;
1839 1855
1840 if (m_readyState >= HAVE_CURRENT_DATA && oldState < HAVE_CURRENT_DATA && !m_ haveFiredLoadedData) { 1856 if (m_readyState >= HAVE_CURRENT_DATA && oldState < HAVE_CURRENT_DATA && !m_ haveFiredLoadedData) {
1841 m_haveFiredLoadedData = true; 1857 m_haveFiredLoadedData = true;
1842 shouldUpdateDisplayState = true; 1858 shouldUpdateDisplayState = true;
1843 scheduleEvent(EventTypeNames::loadeddata); 1859 scheduleEvent(EventTypeNames::loadeddata);
1844 setShouldDelayLoadEvent(false); 1860 setShouldDelayLoadEvent(false);
1845 applyMediaFragmentURI();
1846 } 1861 }
1847 1862
1848 bool isPotentiallyPlaying = potentiallyPlaying(); 1863 bool isPotentiallyPlaying = potentiallyPlaying();
1849 if (m_readyState == HAVE_FUTURE_DATA && oldState <= HAVE_CURRENT_DATA && tra cksAreReady) { 1864 if (m_readyState == HAVE_FUTURE_DATA && oldState <= HAVE_CURRENT_DATA && tra cksAreReady) {
1850 scheduleEvent(EventTypeNames::canplay); 1865 scheduleEvent(EventTypeNames::canplay);
1851 if (isPotentiallyPlaying) 1866 if (isPotentiallyPlaying)
1852 scheduleEvent(EventTypeNames::playing); 1867 scheduleEvent(EventTypeNames::playing);
1853 shouldUpdateDisplayState = true; 1868 shouldUpdateDisplayState = true;
1854 } 1869 }
1855 1870
(...skipping 2006 matching lines...) Expand 10 before | Expand all | Expand 10 after
3862 // or if its media controller position is either before the media resource's earliest possible 3877 // or if its media controller position is either before the media resource's earliest possible
3863 // position relative to the MediaController's timeline or after the end of t he media resource 3878 // position relative to the MediaController's timeline or after the end of t he media resource
3864 // relative to the MediaController's timeline. 3879 // relative to the MediaController's timeline.
3865 double mediaControllerPosition = m_mediaController->currentTime(); 3880 double mediaControllerPosition = m_mediaController->currentTime();
3866 if (mediaControllerPosition < 0 || mediaControllerPosition > duration()) 3881 if (mediaControllerPosition < 0 || mediaControllerPosition > duration())
3867 return true; 3882 return true;
3868 3883
3869 return false; 3884 return false;
3870 } 3885 }
3871 3886
3872 void HTMLMediaElement::prepareMediaFragmentURI()
3873 {
3874 MediaFragmentURIParser fragmentParser(m_currentSrc);
3875 double dur = duration();
3876
3877 double start = fragmentParser.startTime();
3878 if (start != MediaFragmentURIParser::invalidTimeValue() && start > 0) {
3879 m_fragmentStartTime = start;
3880 if (m_fragmentStartTime > dur)
3881 m_fragmentStartTime = dur;
3882 } else
3883 m_fragmentStartTime = MediaPlayer::invalidTime();
3884
3885 double end = fragmentParser.endTime();
3886 if (end != MediaFragmentURIParser::invalidTimeValue() && end > 0 && end > m_ fragmentStartTime) {
3887 m_fragmentEndTime = end;
3888 if (m_fragmentEndTime > dur)
3889 m_fragmentEndTime = dur;
3890 } else
3891 m_fragmentEndTime = MediaPlayer::invalidTime();
3892
3893 // FIXME: Add support for selecting tracks by ID with the Media Fragments tr ack dimension.
3894
3895 if (m_fragmentStartTime != MediaPlayer::invalidTime() && m_readyState < HAVE _FUTURE_DATA)
3896 prepareToPlay();
3897 }
3898
3899 void HTMLMediaElement::applyMediaFragmentURI()
3900 {
3901 if (m_fragmentStartTime != MediaPlayer::invalidTime()) {
3902 m_sentEndEvent = false;
3903 UseCounter::count(document(), UseCounter::HTMLMediaElementSeekToFragment Start);
3904 seek(m_fragmentStartTime);
3905 }
3906 }
3907
3908 WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const 3887 WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const
3909 { 3888 {
3910 const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr); 3889 const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr);
3911 if (crossOriginMode.isNull()) 3890 if (crossOriginMode.isNull())
3912 return WebMediaPlayer::CORSModeUnspecified; 3891 return WebMediaPlayer::CORSModeUnspecified;
3913 if (equalIgnoringCase(crossOriginMode, "use-credentials")) 3892 if (equalIgnoringCase(crossOriginMode, "use-credentials"))
3914 return WebMediaPlayer::CORSModeUseCredentials; 3893 return WebMediaPlayer::CORSModeUseCredentials;
3915 return WebMediaPlayer::CORSModeAnonymous; 3894 return WebMediaPlayer::CORSModeAnonymous;
3916 } 3895 }
3917 3896
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
4001 3980
4002 #if ENABLE(WEB_AUDIO) 3981 #if ENABLE(WEB_AUDIO)
4003 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 3982 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
4004 { 3983 {
4005 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) 3984 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider())
4006 audioSourceProvider()->setClient(0); 3985 audioSourceProvider()->setClient(0);
4007 } 3986 }
4008 #endif 3987 #endif
4009 3988
4010 } 3989 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698