| Aaron Colwell | c6841a0 | 2014-03-07 01:37:56 | [diff] [blame] | 1 | <!DOCTYPE html> |
| Matt Wolenetz | 74803c6 | 2016-08-19 01:46:40 | [diff] [blame] | 2 | <!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). --> |
| Aaron Colwell | c6841a0 | 2014-03-07 01:37:56 | [diff] [blame] | 3 | <html> |
| 4 | <head> |
| Aaron Colwell | aa3c90b | 2014-08-04 17:58:37 | [diff] [blame] | 5 | <title>Simple MediaSource playback & seek test case.</title> |
| Aaron Colwell | 06f8ec2 | 2014-03-07 18:09:47 | [diff] [blame] | 6 | <script src="/resources/testharness.js"></script> |
| 7 | <script src="/resources/testharnessreport.js"></script> |
| Aaron Colwell | c6841a0 | 2014-03-07 01:37:56 | [diff] [blame] | 8 | <script src="mediasource-util.js"></script> |
| Aaron Colwell | c6841a0 | 2014-03-07 01:37:56 | [diff] [blame] | 9 | </head> |
| 10 | <body> |
| 11 | <div id="log"></div> |
| 12 | <script> |
| 13 | |
| 14 | mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData) |
| 15 | { |
| 16 | |
| 17 | mediaElement.play(); |
| 18 | // Append all the segments |
| 19 | test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer'); |
| 20 | test.expectEvent(mediaElement, 'playing', 'Playing triggered'); |
| 21 | sourceBuffer.appendBuffer(mediaData); |
| 22 | |
| 23 | function confirmPlayThenEnd() |
| 24 | { |
| 25 | test.waitForCurrentTimeChange(mediaElement, function () |
| 26 | { |
| 27 | assert_greater_than(mediaElement.currentTime, 0.0, 'Playback has started after seek.'); |
| 28 | test.done(); |
| 29 | }); |
| 30 | } |
| 31 | |
| 32 | function finishSeekThenPlay() |
| 33 | { |
| Aaron Colwell | c6841a0 | 2014-03-07 01:37:56 | [diff] [blame] | 34 | test.expectEvent(mediaElement, 'seeked', 'mediaElement finished seek'); |
| 35 | |
| 36 | test.waitForExpectedEvents(confirmPlayThenEnd); |
| 37 | } |
| 38 | |
| 39 | function delayedPlayHandler() |
| 40 | { |
| 41 | assert_greater_than(mediaElement.currentTime, 0.0, 'Playback has started.'); |
| 42 | test.expectEvent(mediaElement, 'seeking', 'mediaElement'); |
| 43 | mediaElement.currentTime = 0.0; |
| Jean-Yves Avenard | 441c477 | 2016-08-25 12:57:05 | [diff] [blame] | 44 | assert_true(mediaElement.seeking, 'mediaElement is seeking'); |
| Aaron Colwell | c6841a0 | 2014-03-07 01:37:56 | [diff] [blame] | 45 | |
| 46 | test.waitForExpectedEvents(finishSeekThenPlay); |
| 47 | } |
| 48 | |
| 49 | test.waitForExpectedEvents(function() |
| 50 | { |
| 51 | test.waitForCurrentTimeChange(mediaElement, delayedPlayHandler); |
| 52 | }); |
| 53 | |
| 54 | }, 'Test playing then seeking back.'); |
| 55 | </script> |
| 56 | </body> |
| 57 | </html> |