| <!DOCTYPE html> |
| <html> |
| <head> |
| <title>media-source-resize</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; |
| }); |
| } |
| |
| window.addEventListener('load', async event => { |
| 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(video, 'error').then(failTest); |
| |
| run('sourceBuffer = source.addSourceBuffer(loader.type())'); |
| run('sourceBuffer.appendBuffer(loader.initSegment())'); |
| await waitFor(sourceBuffer, 'update'); |
| |
| consoleWrite('<br>Append all media segments') |
| for (i = 0; i < loader.mediaSegmentsLength(); i++) { |
| run(`sourceBuffer.appendBuffer(loader.mediaSegment(${i}))`); |
| await waitFor(sourceBuffer, 'update'); |
| } |
| |
| consoleWrite('<br>Seek and play') |
| let seekTime = 1.6; |
| run(`video.currentTime = ${seekTime}`); |
| await waitFor(video, 'seeked'); |
| testExpected('video.currentTime', seekTime); |
| run('video.play()'); |
| |
| consoleWrite(''); |
| let count = 0; |
| waitForEvent('timeupdate', (evt) => { |
| testExpected('video.currentTime', seekTime, '>='); |
| |
| if (++count == 5) { |
| consoleWrite('') |
| endTest(); |
| } |
| }); |
| }); |
| |
| </script> |
| </head> |
| <body> |
| <video controls></video> |
| </body> |
| </html> |