| <!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 counter = 0; |
| |
| if (window.internals) |
| internals.initializeMockMediaSource(); |
| |
| function runTest() { |
| findMediaElement(); |
| source = new MediaSource(); |
| waitForEvent('sourceopen', sourceOpen, false, false, source); |
| run('video.src = URL.createObjectURL(source)'); |
| } |
| |
| function sourceOpen() { |
| run('sourceBuffer1 = source.addSourceBuffer("audio/mock; codecs=mock")'); |
| run('sourceBuffer2 = source.addSourceBuffer("video/mock; codecs=mock")'); |
| |
| waitForEventOn(sourceBuffer1, 'updateend', update1, false, true); |
| waitForEventOn(sourceBuffer2, 'updateend', update2, false, true); |
| waitForEventOnce('loadedmetadata', loadedMetadata); |
| |
| initSegment = makeAInit(0, [makeATrack(1, 'mock', TRACK_KIND.AUDIO)]); |
| run('sourceBuffer1.appendBuffer(initSegment)'); |
| } |
| |
| function update1() { |
| counter++; |
| initSegment = makeAInit(0, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)]); |
| setTimeout(function () { |
| run('sourceBuffer2.appendBuffer(initSegment)'); |
| }, 200); |
| } |
| |
| function update2() { |
| counter++; |
| setTimeout(function () { |
| if (counter==3) endTest(); |
| }, 200); |
| } |
| |
| function loadedMetadata() { |
| counter++; |
| setTimeout(function () { |
| testExpected('source.activeSourceBuffers.length', 2); |
| if (counter==3) endTest(); |
| }, 200); |
| } |
| |
| </script> |
| </head> |
| <body onload="runTest()"> |
| <video></video> |
| </body> |
| </html> |