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 1630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1641 // This is needed to avoid getting default playback start position from curr
entTime(). | 1641 // This is needed to avoid getting default playback start position from curr
entTime(). |
1642 double now = m_cachedTime; | 1642 double now = m_cachedTime; |
1643 | 1643 |
1644 // 3 - If the element's seeking IDL attribute is true, then another instance
of this algorithm is | 1644 // 3 - If the element's seeking IDL attribute is true, then another instance
of this algorithm is |
1645 // already running. Abort that other instance of the algorithm without waiti
ng for the step that | 1645 // already running. Abort that other instance of the algorithm without waiti
ng for the step that |
1646 // it is running to complete. | 1646 // it is running to complete. |
1647 // Nothing specific to be done here. | 1647 // Nothing specific to be done here. |
1648 | 1648 |
1649 // 4 - Set the seeking IDL attribute to true. | 1649 // 4 - Set the seeking IDL attribute to true. |
1650 // The flag will be cleared when the engine tells us the time has actually c
hanged. | 1650 // The flag will be cleared when the engine tells us the time has actually c
hanged. |
1651 bool previousSeekStillPending = m_seeking; | |
1652 m_seeking = true; | 1651 m_seeking = true; |
1653 | 1652 |
1654 // 6 - If the new playback position is later than the end of the media resou
rce, then let it be the end | 1653 // 6 - If the new playback position is later than the end of the media resou
rce, then let it be the end |
1655 // of the media resource instead. | 1654 // of the media resource instead. |
1656 time = std::min(time, duration()); | 1655 time = std::min(time, duration()); |
1657 | 1656 |
1658 // 7 - If the new playback position is less than the earliest possible posit
ion, let it be that position instead. | 1657 // 7 - If the new playback position is less than the earliest possible posit
ion, let it be that position instead. |
1659 time = std::max(time, 0.0); | 1658 time = std::max(time, 0.0); |
1660 | 1659 |
1661 // Ask the media engine for the time value in the movie's time scale before
comparing with current time. This | 1660 // Ask the media engine for the time value in the movie's time scale before
comparing with current time. This |
1662 // is necessary because if the seek time is not equal to currentTime but the
delta is less than the movie's | 1661 // is necessary because if the seek time is not equal to currentTime but the
delta is less than the movie's |
1663 // time scale, we will ask the media engine to "seek" to the current movie t
ime, which may be a noop and | 1662 // time scale, we will ask the media engine to "seek" to the current movie t
ime, which may be a noop and |
1664 // not generate a timechanged callback. This means m_seeking will never be c
leared and we will never | 1663 // not generate a timechanged callback. This means m_seeking will never be c
leared and we will never |
1665 // fire a 'seeked' event. | 1664 // fire a 'seeked' event. |
1666 double mediaTime = webMediaPlayer()->mediaTimeForTimeValue(time); | 1665 double mediaTime = webMediaPlayer()->mediaTimeForTimeValue(time); |
1667 if (time != mediaTime) { | 1666 if (time != mediaTime) { |
1668 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f) - media timeline equivale
nt is %f", this, time, mediaTime); | 1667 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f) - media timeline equivale
nt is %f", this, time, mediaTime); |
1669 time = mediaTime; | 1668 time = mediaTime; |
1670 } | 1669 } |
1671 | 1670 |
1672 // 8 - If the (possibly now changed) new playback position is not in one of
the ranges given in the | 1671 // 8 - If the (possibly now changed) new playback position is not in one of
the ranges given in the |
1673 // seekable attribute, then let it be the position in one of the ranges give
n in the seekable attribute | 1672 // seekable attribute, then let it be the position in one of the ranges give
n in the seekable attribute |
1674 // that is the nearest to the new playback position. ... If there are no ran
ges given in the seekable | 1673 // that is the nearest to the new playback position. ... If there are no ran
ges given in the seekable |
1675 // attribute then set the seeking IDL attribute to false and abort these ste
ps. | 1674 // attribute then set the seeking IDL attribute to false and abort these ste
ps. |
1676 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable(); | 1675 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable(); |
1677 | 1676 |
1678 // Short circuit seeking to the current time by just firing the events if no
seek is required. | 1677 if (!seekableRanges->length()) { |
1679 // Don't skip calling the media engine if we are in poster mode because a se
ek should always | |
1680 // cancel poster display. | |
1681 bool noSeekRequired = !seekableRanges->length() || (time == now && displayMo
de() != Poster); | |
1682 | |
1683 if (noSeekRequired) { | |
1684 if (time == now) { | |
1685 scheduleEvent(EventTypeNames::seeking); | |
1686 if (previousSeekStillPending) | |
1687 return; | |
1688 // FIXME: There must be a stable state before timeupdate+seeked are
dispatched and seeking | |
1689 // is reset to false. See http://crbug.com/266631 | |
1690 scheduleTimeupdateEvent(false); | |
1691 scheduleEvent(EventTypeNames::seeked); | |
1692 } | |
1693 m_seeking = false; | 1678 m_seeking = false; |
1694 return; | 1679 return; |
1695 } | 1680 } |
1696 time = seekableRanges->nearest(time, now); | 1681 time = seekableRanges->nearest(time, now); |
1697 | 1682 |
1698 if (m_playing) { | 1683 if (m_playing && m_lastSeekTime < now) |
1699 if (m_lastSeekTime < now) | 1684 addPlayedRange(m_lastSeekTime, now); |
1700 addPlayedRange(m_lastSeekTime, now); | 1685 |
1701 } | |
1702 m_lastSeekTime = time; | 1686 m_lastSeekTime = time; |
1703 m_sentEndEvent = false; | 1687 m_sentEndEvent = false; |
1704 | 1688 |
1705 // 10 - Queue a task to fire a simple event named seeking at the element. | 1689 // 10 - Queue a task to fire a simple event named seeking at the element. |
1706 scheduleEvent(EventTypeNames::seeking); | 1690 scheduleEvent(EventTypeNames::seeking); |
1707 | 1691 |
1708 // 11 - Set the current playback position to the given new playback position
. | 1692 // 11 - Set the current playback position to the given new playback position
. |
1709 webMediaPlayer()->seek(time); | 1693 webMediaPlayer()->seek(time); |
1710 | 1694 |
1711 m_initialPlayWithoutUserGestures = false; | 1695 m_initialPlayWithoutUserGestures = false; |
(...skipping 2075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3787 visitor->trace(m_client); | 3771 visitor->trace(m_client); |
3788 } | 3772 } |
3789 | 3773 |
3790 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) | 3774 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) |
3791 { | 3775 { |
3792 visitor->trace(m_client); | 3776 visitor->trace(m_client); |
3793 } | 3777 } |
3794 #endif | 3778 #endif |
3795 | 3779 |
3796 } | 3780 } |
OLD | NEW |