| <!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 sample; |
| |
| if (window.internals) |
| internals.initializeMockMediaSource(); |
| |
| function runTest() { |
| findMediaElement(); |
| |
| source = new MediaSource(); |
| waitForEventOn(source, 'sourceopen', sourceOpen); |
| video.src = URL.createObjectURL(source); |
| } |
| |
| function sourceOpen() { |
| run('sourceBuffer = source.addSourceBuffer("video/mock; codecs=mock")'); |
| waitForEventOn(sourceBuffer, 'updateend', loadSamples, false, true); |
| initSegment = makeAInit(0, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)]); |
| run('sourceBuffer.appendBuffer(initSegment)'); |
| } |
| |
| function loadSamples() { |
| testExpected('video.duration', 0); |
| sample = makeASample(0, 0, 10, 1, SAMPLE_FLAG.SYNC); |
| waitForEventOn(sourceBuffer, 'updateend', checkDuration, false, true); |
| run('sourceBuffer.appendBuffer(sample)'); |
| } |
| |
| function checkDuration() { |
| testExpected('video.duration', 10); |
| endTest(); |
| } |
| |
| </script> |
| </head> |
| <body onload="runTest()"> |
| <video></video> |
| </body> |
| </html> |