Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Add support for HTMLMediaElement.fastSeek()
https://bugs.webkit.org/show_bug.cgi?id=124262 Reviewed by Eric Carlson. Source/WebCore: Test: media/video-fast-seek.html Add the fastSeek() method to HTMLMediaElement, and use fastSeek() in the JavaScript media controls. Add the new fastSeek() method: * html/HTMLMediaElement.cpp: (HTMLMediaElement::fastSeek): Call seekWithTolerance. (HTMLMediaElement::seek): Call seekWithTolerance with 0 tolerance. (HTMLMediaElement::seekWithTolerance): Renamed from seek(). * html/HTMLMediaElement.h: * html/HTMLMediaElement.idl: Add seekWithTolerance() to MediaPlayer: * platform/graphics/MediaPlayer.cpp: (WebCore::MediaPlayer::seekWithTolerance): Pass to MediaPlayerPrivate. * platform/graphics/MediaPlayer.h: * platform/graphics/MediaPlayerPrivate.h: (WebCore::MediaPlayerPrivateInterface::seekWithTolerance): Default implementation which calls seek(). * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::seek): Call seekWithTolerance with 0 tolerance. (WebCore::MediaPlayerPrivateAVFoundation::seekWithTolerance): Renamed from seek(). * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::MediaPlayerPrivateAVFoundationObjC::seekToTime): Take tolerance parameters. Use the new fastSeek() method while actively scrubbing. * Modules/mediacontrols/mediaControlsApple.js: (Controller.prototype.createControls): Add mouse up and down handlers. (Controller.prototype.handleTimeUpdate): Only update the timeline when not scrubbing. (Controller.prototype.handleTimelineChange): Use fastSeek(). (Controller.prototype.handleTimelineMouseDown): Start scrubbing. (Controller.prototype.handleTimelineMouseUp): Stop scrubbing. LayoutTests: * media/video-fast-seek-expected.txt: Added. * media/video-fast-seek.html: Added. Canonical link: https://commits.webkit.org/142492@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@159208 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
15 changed files
with
203 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Test that fastSeek() commands work correctly. | ||
|
||
EVENT(canplaythrough) | ||
Seek past the 4th sync sample: | ||
RUN(video.currentTime = 2.5) | ||
EVENT(timeupdate) | ||
EXPECTED (video.currentTime == '2.5') OK | ||
Test that fastSeek() past the currentTime will not result in a seek before the currentTime: | ||
RUN(video.fastSeek(2.6)) | ||
EVENT(timeupdate) | ||
EXPECTED (video.currentTime >= '2.6') OK | ||
Seek before the 4th sync sample: | ||
RUN(video.currentTime = 2.3) | ||
EVENT(timeupdate) | ||
EXPECTED (video.currentTime == '2.3') OK | ||
Test that fastSeek() before the currentTime will not result in a seek past the currentTime: | ||
RUN(video.fastSeek(2.2)) | ||
EVENT(timeupdate) | ||
EXPECTED (video.currentTime <= '2.2') OK | ||
END OF TEST | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src=media-file.js></script> | ||
<script src=video-test.js></script> | ||
<script> | ||
|
||
// The test.mp4 file has sync samples at the following presentation time stamps: | ||
// 0.0000, 0.7968, 1.5936, 2.3904, 3.1872, 3.9840, 4.7808, 5.5776 | ||
|
||
function runTest() | ||
{ | ||
findMediaElement(); | ||
waitForEvent('canplaythrough', canplaythrough); | ||
|
||
// Other media files may have sync samples at completely different points, so | ||
// explicitly use the .mp4 here. | ||
video.src = "content/test.mp4"; | ||
} | ||
|
||
function canplaythrough() | ||
{ | ||
waitForEventOnce('timeupdate', seek1); | ||
consoleWrite('Seek past the 4th sync sample:'); | ||
run('video.currentTime = 2.5'); | ||
} | ||
|
||
function seek1() | ||
{ | ||
testExpected('video.currentTime', 2.5); | ||
consoleWrite('Test that fastSeek() past the currentTime will not result in a seek before the currentTime:'); | ||
waitForEventOnce('timeupdate', seek2); | ||
run('video.fastSeek(2.6)'); | ||
} | ||
|
||
function seek2() | ||
{ | ||
testExpected('video.currentTime', 2.6, '>='); | ||
consoleWrite('Seek before the 4th sync sample:'); | ||
waitForEventOnce('timeupdate', seek3); | ||
run('video.currentTime = 2.3'); | ||
} | ||
|
||
function seek3() | ||
{ | ||
testExpected('video.currentTime', 2.3); | ||
consoleWrite('Test that fastSeek() before the currentTime will not result in a seek past the currentTime:'); | ||
waitForEventOnce('timeupdate', seek4); | ||
run('video.fastSeek(2.2)'); | ||
} | ||
|
||
function seek4() | ||
{ | ||
testExpected('video.currentTime', 2.2, '<='); | ||
endTest(); | ||
} | ||
|
||
</script> | ||
</head> | ||
<body onload="runTest()"> | ||
<video controls></video> | ||
<p>Test that fastSeek() commands work correctly.</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters