| <!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(); |
| testExpected('source.readyState', 'closed'); |
| |
| 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(100, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)]); |
| run('sourceBuffer.appendBuffer(initSegment)'); |
| } |
| |
| function loadSamples() { |
| sample = makeASample(0, 0, 10, 1, 1, SAMPLE_FLAG.SYNC); |
| waitForEventOn(sourceBuffer, 'updateend', play, false, true); |
| run('sourceBuffer.appendBuffer(sample)'); |
| } |
| |
| function play() { |
| waitForEvent('ended', endTest); |
| run('source.duration = 1'); |
| run('source.endOfStream()'); |
| run('video.play()'); |
| } |
| |
| </script> |
| </head> |
| <body onload="runTest()"> |
| <video></video> |
| </body> |
| </html> |