// eslint-disable-next-line no-undef var helper = new CaptureStreamTestHelper2D(100, 100);
helper.drawColor(canvas, helper.red);
// Draw repeatedly to speed up delivery of the first "dataavailable" event.
let drawing =
helper.startDrawing(helper.drawColor.bind(helper, canvas, helper.red));
var stream = canvas.captureStream();
let mediaRecorder = new MediaRecorder(stream);
is(mediaRecorder.stream, stream, "Media recorder stream = canvas stream at the start of recording");
mediaRecorder.ondataavailable = ev => {
info("Got 'dataavailable' event");
// We just want one frame encoded, to see that the recorder produces something readable.
mediaRecorder.stop();
mediaRecorder.ondataavailable = null;
drawing.stop();
var xhr = new XMLHttpRequest();
xhr.open("POST", "blob_verify.sjs", true);
xhr.onload = () => { varvideo = document.createElement("video"); video.id = "recorded-video"; video.src = URL.createObjectURL(xhr.response); video.play(); video.onerror = () => {
ok(false, "Should be able to play the recording. Got error. code=" + video.error.code);
SimpleTest.finish();
};
document.getElementById("content").appendChild(video);
helper.pixelMustBecome(video, helper.red, {
threshold: 128,
infoString: "Should become red",
}).then(SimpleTest.finish);
};
xhr.onerror = () => {
ok(false, "XHR error");
SimpleTest.finish();
};
xhr.responseType = "blob";
xhr.send(ev.data);
};
mediaRecorder.start(1);
is(mediaRecorder.state, "recording", "Media recorder should be recording");
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.