| <!DOCTYPE html> |
| <html> |
| <head> |
| <title>mock-media-source</title> |
| <script src="mock-media-source.js"></script> |
| <script src="../video-test.js"></script> |
| <script> |
| var source; |
| var sourceBuffer1; |
| var sourceBuffer2; |
| var initSegment; |
| var mediaSegment; |
| |
| if (window.internals) |
| internals.initializeMockMediaSource(); |
| |
| function runTest() { |
| findMediaElement(); |
| |
| source = new MediaSource(); |
| waitForEventOn(source, 'sourceopen', sourceOpen, false, true); |
| run('video.src = URL.createObjectURL(source)'); |
| } |
| |
| function sourceOpen() { |
| run('sourceBuffer1 = source.addSourceBuffer("video/mock; codecs=mock")'); |
| waitForEventOn(sourceBuffer1, 'updateend', updateEndInit1); |
| mediaSegment = concatenateSamples([ |
| makeAInit(10, [makeATrack(1, 'mock', TRACK_KIND.AUDIO)]), |
| makeASample(0, 0, 10, 1, 1, SAMPLE_FLAG.SYNC, 0), |
| ]); |
| run('sourceBuffer1.appendBuffer(mediaSegment)'); |
| } |
| |
| function updateEndInit1() { |
| run('sourceBuffer2 = source.addSourceBuffer("video/mock; codecs=mock")'); |
| waitForEventOn(sourceBuffer2, 'updateend', updateEndInit2); |
| mediaSegment = concatenateSamples([ |
| makeAInit(10, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)]), |
| makeASample(0, 0, 5, 1, 1, SAMPLE_FLAG.SYNC, 0), |
| ]); |
| run('sourceBuffer2.appendBuffer(mediaSegment)'); |
| } |
| |
| function updateEndInit2() { |
| run('source.endOfStream()'); |
| waitForEvent('seeked', seeked); |
| run('video.currentTime = 5'); |
| } |
| |
| function seeked() { |
| run('video.play()'); |
| waitForEventAndEnd('playing'); |
| waitForEventAndFail('waiting'); |
| } |
| |
| </script> |
| </head> |
| <body onload="runTest()"> |
| <video></video> |
| </body> |
| </html> |