| <!DOCTYPE html> |
| <html> |
| <head> |
| <title>media-source-abort-resets-parser</title> |
| <script src="media-source-loader.js"></script> |
| <script src="../video-test.js"></script> |
| <script> |
| var loader; |
| var source; |
| var sourceBuffer; |
| |
| function runTest() { |
| findMediaElement(); |
| |
| loader = new MediaSourceLoader('content/test-fragmented-manifest.json'); |
| loader.onload = mediaDataLoaded; |
| loader.onerror = mediaDataLoadingFailed; |
| } |
| |
| function mediaDataLoadingFailed() { |
| failTest('Media data loading failed'); |
| } |
| |
| function mediaDataLoaded() { |
| source = new MediaSource(); |
| waitForEvent('sourceopen', sourceOpen, false, false, source); |
| run('video.src = URL.createObjectURL(source)'); |
| } |
| |
| function sourceOpen() { |
| run('source.duration = loader.duration()'); |
| run('sourceBuffer = source.addSourceBuffer(loader.type())'); |
| waitForEventOn(sourceBuffer, 'update', sourceInitialized, false, true); |
| run('sourceBuffer.appendBuffer(loader.initSegment())'); |
| } |
| |
| function sourceInitialized() { |
| consoleWrite('Append a media segment.') |
| waitForEventOn(sourceBuffer, 'update', mediaSegmentAppended, false, true); |
| run('sourceBuffer.appendBuffer(loader.mediaSegment(0))'); |
| } |
| |
| function mediaSegmentAppended() { |
| loader = new MediaSourceLoader('content/test-48khz-manifest.json'); |
| loader.onload = audioMediaDataLoaded; |
| loader.onerror = mediaDataLoadingFailed; |
| } |
| |
| function audioMediaDataLoaded() { |
| run('video.currentTime = 1.5'); |
| consoleWrite('Generate an error by appending an initialization segment with a different number of tracks, which will cause the MediaSource to detach.'); |
| run('sourceBuffer.appendBuffer(loader.initSegment())'); |
| setTimeout(() => { run('video.currentTime = 2'); }); |
| video.addEventListener('error', endTestLater); |
| } |
| </script> |
| </head> |
| <body onload="runTest()"> |
| <video controls></video> |
| </body> |
| </html> |