blob: c67a44462a83cc9939d6b564e48cc3f8db3e2095 [file] [log] [blame]
<!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 requestLength = 200000;
var nextRequest = 0;
var totalLength = 100;
if (window.internals)
internals.initializeMockMediaSource();
function runTest()
{
findMediaElement();
source = new MediaSource();
source.addEventListener('sourceopen', startLoad);
waitForEvent('loadedmetadata');
waitForEvent('loadeddata');
waitForEvent('canplay');
waitForEventAndEnd('canplaythrough');
run('video.src = URL.createObjectURL(source)');
}
function startLoad()
{
sourceBuffer = source.addSourceBuffer('video/mock; codecs="mock"');
sourceBuffer.addEventListener('update', sourceUpdated);
nextRequest = 0;
// Make an init segment with 1 video track
var init = makeAInit(100, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)]);
sourceBuffer.appendBuffer(init)
}
function sourceUpdated()
{
source.activeSourceBuffers.length;
if (nextRequest < totalLength) {
sourceBuffer.appendBuffer(makeASample(nextRequest, nextRequest, 1, 1, SAMPLE_FLAG.SYNC));
++nextRequest;
}
}
</script>
</head>
<body onload="runTest()">
<video controls width=960 height=510></video>
</body>
</html>