gecko/browser/base/content/test/general/get_user_media.html

49 lines
1.2 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"></head>
<body>
<div id="message"></div>
<script>
// Specifies whether we are using fake streams to run this automation
var useFakeStreams = true;
try {
var audioDevice = SpecialPowers.getCharPref("media.audio_loopback_dev");
var videoDevice = SpecialPowers.getCharPref("media.video_loopback_dev");
dump("TEST DEVICES: Using media devices:\n");
dump("audio: " + audioDevice + "\nvideo: " + videoDevice + "\n");
useFakeStreams = false;
} catch (e) {
dump("TEST DEVICES: No test devices found (in media.{audio,video}_loopback_dev, using fake streams.\n");
useFakeStreams = true;
}
function message(m) {
document.getElementById("message").innerHTML = m;
window.parent.postMessage(m, "*");
}
var gStream;
function requestDevice(aAudio, aVideo) {
var opts = {video: aVideo, audio: aAudio};
if (useFakeStreams) {
opts.fake = true;
}
window.navigator.mozGetUserMedia(opts, function(stream) {
gStream = stream;
message("ok");
}, function(err) { message("error: " + err); });
}
message("pending");
function closeStream() {
if (!gStream)
return;
gStream.stop();
gStream = null;
message("closed");
}
</script>
</body>
</html>