| <!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 sourceBuffer; |
| var initSegment; |
| var samples; |
| |
| if (window.internals) |
| internals.initializeMockMediaSource(); |
| |
| function runTest() { |
| findMediaElement(); |
| |
| source = new MediaSource(); |
| testExpected('source.readyState', 'closed'); |
| |
| waitForEventOn(source, 'sourceopen', sourceOpen); |
| var videoSource = document.createElement('source'); |
| videoSource.type = 'video/mock; codecs=mock'; |
| videoSource.src = URL.createObjectURL(source); |
| video.appendChild(videoSource); |
| } |
| |
| function sourceOpen() { |
| run('sourceBuffer = source.addSourceBuffer("video/mock; codecs=mock")'); |
| waitForEventOn(sourceBuffer, 'updateend', loadSamples, false, true); |
| initSegment = makeAInit(8, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)]); |
| run('sourceBuffer.appendBuffer(initSegment)'); |
| } |
| |
| function loadSamples() { |
| samples = concatenateSamples([ |
| makeASample(1, 0, 1, 1, 1, SAMPLE_FLAG.SYNC), |
| makeASample(2, 1, 1, 1, 1, SAMPLE_FLAG.NONE), |
| makeASample(3, 2, 1, 1, 1, SAMPLE_FLAG.NONE), |
| makeASample(4, 3, 1, 1, 1, SAMPLE_FLAG.SYNC), |
| makeASample(6, 4, 1, 1, 1, SAMPLE_FLAG.NONE), |
| makeASample(5, 5, 1, 1, 1, SAMPLE_FLAG.NONE), |
| ]); |
| waitForEventOn(sourceBuffer, 'updateend', loadMoreSamples, false, true); |
| run('sourceBuffer.appendBuffer(samples)'); |
| } |
| |
| function loadMoreSamples() { |
| samples = concatenateSamples([ |
| makeASample(1, 0, 1, 1, 1, SAMPLE_FLAG.SYNC), |
| makeASample(2, 1, 1, 1, 1, SAMPLE_FLAG.NONE), |
| makeASample(3, 2, 1, 1, 1, SAMPLE_FLAG.NONE), |
| makeASample(4, 3, 1, 1, 1, SAMPLE_FLAG.SYNC), |
| makeASample(6, 4, 1, 1, 1, SAMPLE_FLAG.NONE), |
| makeASample(5, 5, 1, 1, 1, SAMPLE_FLAG.NONE), |
| ]); |
| waitForEventOn(sourceBuffer, 'updateend', loadComplete, false, true); |
| run('sourceBuffer.appendBuffer(samples)'); |
| } |
| |
| function loadComplete() { |
| testExpected('video.buffered.length', 1); |
| testExpected('video.buffered.start(0).toFixed(3)', 1); |
| testExpected('video.buffered.end(0).toFixed(3)', 7); |
| endTest(); |
| } |
| |
| </script> |
| </head> |
| <body onload="runTest()"> |
| <video></video> |
| </body> |
| </html> |