| <!DOCTYPE html> |
| <html> |
| <head> |
| <title>media-source-unexpected-pause</title> |
| <script src="media-source-loader.js"></script> |
| <script src="../video-test.js"></script> |
| <script> |
| var loader; |
| var source; |
| var sourceBuffer; |
| |
| function loaderPromise(loader) { |
| return new Promise((resolve, reject) => { |
| loader.onload = resolve; |
| loader.onerror = reject; |
| }); |
| } |
| |
| async function runTest() { |
| findMediaElement(); |
| loader = new MediaSourceLoader('content/test-fragmented-manifest.json'); |
| await loaderPromise(loader); |
| |
| source = new MediaSource(); |
| run('video.src = URL.createObjectURL(source)'); |
| await waitFor(source, 'sourceopen'); |
| waitFor(source, 'error').then(endTest); |
| waitForEventAndFail('error'); |
| |
| run('source.duration = loader.duration()'); |
| run('sourceBuffer = source.addSourceBuffer(loader.type())'); |
| run('sourceBuffer.appendBuffer(loader.initSegment())'); |
| |
| await waitFor(sourceBuffer, 'update'); |
| |
| consoleWrite('Append a media segment.') |
| run('sourceBuffer.appendBuffer(loader.mediaSegment(0))'); |
| |
| await waitFor(sourceBuffer, 'update'); |
| await sleepFor(100); |
| |
| run('video.play()'); |
| await waitFor(video, 'playing'); |
| await sleepFor(100); |
| run('video.pause()'); |
| await sleepFor(0); |
| await sleepFor(0); |
| run('video.play()'); |
| waitForAndFail(video, 'pause'); |
| await waitFor(video, 'playing'); |
| await sleepFor(100); |
| } |
| |
| window.addEventListener('load', event => { |
| runTest().then(endTest).catch(failTest); |
| }); |
| </script> |
| </head> |
| <body> |
| <video muted controls></video> |
| </body> |
| </html> |