| 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 test case.</title> |
| Matt Wolenetz | 11147d0 | 2019-06-13 23:52:47 | [diff] [blame] | 6 | <meta name="timeout" content="long"> |
| Aaron Colwell | 06f8ec2 | 2014-03-07 18:09:47 | [diff] [blame] | 7 | <script src="/resources/testharness.js"></script> |
| 8 | <script src="/resources/testharnessreport.js"></script> |
| Aaron Colwell | c6841a0 | 2014-03-07 01:37:56 | [diff] [blame] | 9 | <script src="mediasource-util.js"></script> |
| Aaron Colwell | c6841a0 | 2014-03-07 01:37:56 | [diff] [blame] | 10 | </head> |
| 11 | <body> |
| 12 | <div id="log"></div> |
| 13 | <script> |
| 14 | mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData) |
| 15 | { |
| Ms2ger | 979de36 | 2015-06-29 10:21:19 | [diff] [blame] | 16 | mediaElement.addEventListener('error', test.unreached_func("Unexpected event 'error'")); |
| Ms2ger | edb207d | 2015-06-29 10:31:57 | [diff] [blame] | 17 | mediaElement.addEventListener('ended', test.step_func_done()); |
| Aaron Colwell | c6841a0 | 2014-03-07 01:37:56 | [diff] [blame] | 18 | |
| Aaron Colwell | cffb8af | 2014-05-23 22:27:10 | [diff] [blame] | 19 | test.expectEvent(sourceBuffer, 'updatestart', 'sourceBuffer'); |
| 20 | test.expectEvent(sourceBuffer, 'update', 'sourceBuffer'); |
| 21 | test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer'); |
| Aaron Colwell | c6841a0 | 2014-03-07 01:37:56 | [diff] [blame] | 22 | |
| Chris Cunningham | 5d2bdef | 2018-01-17 20:45:27 | [diff] [blame] | 23 | assert_false(sourceBuffer.updating, "sourceBuffer.updating"); |
| 24 | |
| Aaron Colwell | c6841a0 | 2014-03-07 01:37:56 | [diff] [blame] | 25 | sourceBuffer.appendBuffer(mediaData); |
| Aaron Colwell | cffb8af | 2014-05-23 22:27:10 | [diff] [blame] | 26 | |
| Chris Cunningham | 5d2bdef | 2018-01-17 20:45:27 | [diff] [blame] | 27 | assert_true(sourceBuffer.updating, "sourceBuffer.updating"); |
| 28 | |
| Aaron Colwell | cffb8af | 2014-05-23 22:27:10 | [diff] [blame] | 29 | test.waitForExpectedEvents(function() |
| 30 | { |
| Chris Cunningham | 5d2bdef | 2018-01-17 20:45:27 | [diff] [blame] | 31 | assert_false(sourceBuffer.updating, "sourceBuffer.updating"); |
| Aaron Colwell | cffb8af | 2014-05-23 22:27:10 | [diff] [blame] | 32 | |
| Chris Cunningham | 5d2bdef | 2018-01-17 20:45:27 | [diff] [blame] | 33 | // Truncate the buffered media to about 1 second duration. |
| 34 | sourceBuffer.remove(1, +Infinity); |
| Aaron Colwell | cffb8af | 2014-05-23 22:27:10 | [diff] [blame] | 35 | |
| Chris Cunningham | 5d2bdef | 2018-01-17 20:45:27 | [diff] [blame] | 36 | assert_true(sourceBuffer.updating, "sourceBuffer.updating"); |
| Aaron Colwell | cffb8af | 2014-05-23 22:27:10 | [diff] [blame] | 37 | test.expectEvent(sourceBuffer, 'updatestart', 'sourceBuffer'); |
| 38 | test.expectEvent(sourceBuffer, 'update', 'sourceBuffer'); |
| 39 | test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer'); |
| 40 | }); |
| 41 | |
| 42 | test.waitForExpectedEvents(function() |
| 43 | { |
| Jean-Yves Avenard | 1ad8d4d | 2016-08-01 14:14:16 | [diff] [blame] | 44 | assert_false(sourceBuffer.updating, "updating"); |
| 45 | assert_greater_than(mediaSource.duration, 1, "duration"); |
| 46 | |
| Chris Cunningham | 5d2bdef | 2018-01-17 20:45:27 | [diff] [blame] | 47 | // Complete truncation of duration to 1 second. |
| Jean-Yves Avenard | 1ad8d4d | 2016-08-01 14:14:16 | [diff] [blame] | 48 | mediaSource.duration = 1; |
| 49 | |
| 50 | test.expectEvent(mediaElement, "durationchange"); |
| 51 | }); |
| 52 | |
| 53 | test.waitForExpectedEvents(function() |
| 54 | { |
| Aaron Colwell | cffb8af | 2014-05-23 22:27:10 | [diff] [blame] | 55 | mediaSource.endOfStream(); |
| 56 | mediaElement.play(); |
| 57 | }); |
| James Graham | 1da6470 | 2015-05-01 12:22:22 | [diff] [blame] | 58 | }, "Test normal playback case with MediaSource API"); |
| Aaron Colwell | c6841a0 | 2014-03-07 01:37:56 | [diff] [blame] | 59 | </script> |
| 60 | </body> |
| 61 | </html> |