Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/browser/base/content/test/webrtc/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 3 kB image not shown  

Quelle  get_user_media.html   Sprache: HTML

 

 products/Sources/formale Sprachen/C/Firefox/browser/base/content/test/webrtc/get_user_media.html


<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"></head>
<body>
<div id="message"></div>
<button id="gum">getUserMedia</button>
<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}<br>`;
  top.postMessage(m, "*");
}

var gStreams = [];
var gVideoEvents = [];
var gAudioEvents = [];

/**
 * Queue a getUserMedia request to be triggered by a button click.
 * The button click needs to be handled by the caller.
 *
 * @param {boolean} aAudio - Whether to request audio.
 * @param {boolean} aVideo - Whether to request video.
 * @param {number} aShare - The type of screen sharing.
 * @param {boolean} aBadDevice - Whether to use a bad device ID.
 * @param {boolean} withUserActivation - Whether to simulate user activation.
 * @returns {Promise} - Resolves when the requestDevice call completes.
 */
function queueRequestDeviceViaBtn(aAudio, aVideo, aShare, aBadDevice = false) {
  return new Promise((resolve) => {
    let button = document.getElementById("gum");
    button.addEventListener("click", () => {
      button.innerText = "getUserMedia";
      requestDevice(aAudio, aVideo, aShare, aBadDevice).then(resolve);
    }, {once: true});
    button.innerText =
      `getUserMedia(${aAudio}, ${aVideo}, ${aShare}, ${aBadDevice})`;
  });
}

async function requestDevice(aAudio, aVideo, aShare, aBadDevice = false) {
  const opts = {video: aVideo, audio: aAudio};
  if (aShare) {
    opts.video = { mediaSource: aShare };
    SpecialPowers.wrap(document).notifyUserGestureActivation();
  }
  if (useFakeStreams) {
    opts.fake = true;
  }

  if (aVideo && aBadDevice) {
    opts.video = {
      deviceId: "bad device",
    };
    opts.fake = true;
  }

  if (aAudio && aBadDevice) {
    opts.audio = {
      deviceId: "bad device",
    };
    opts.fake = true;
  }

  try {
    const stream = await navigator.mediaDevices.getUserMedia(opts)
    gStreams.push(stream);

    const videoTrack = stream.getVideoTracks()[0];
    if (videoTrack) {
      for (const name of ["mute", "unmute", "ended"]) {
        videoTrack.addEventListener(name, () => gVideoEvents.push(name));
      }
    }

    const audioTrack = stream.getAudioTracks()[0];
    if (audioTrack) {
      for (const name of ["mute", "unmute", "ended"]) {
        audioTrack.addEventListener(name, () => gAudioEvents.push(name));
      }
    }
    message("ok");
  } catch (err) {
    message("error: " + err);
  }
}

let selectedAudioOutputId;
async function requestAudioOutput(options = {}) {
  const audioOutputOptions = options.requestSameDevice && {
    deviceId: selectedAudioOutputId,
  };
  SpecialPowers.wrap(document).notifyUserGestureActivation();
  try {
    ({ deviceId: selectedAudioOutputId } =
     await navigator.mediaDevices.selectAudioOutput(audioOutputOptions));
    message("ok");
  } catch (err) {
    message("error: " + err);
  }
}

message("pending");

function stopTracks(aKind) {
  for (let stream of gStreams) {
    for (let track of stream.getTracks()) {
      if (track.kind == aKind) {
        track.stop();
        stream.removeTrack(track);
      }
    }
  }
  gStreams = gStreams.filter(s => !!s.getTracks().length);
  if (aKind == "video") {
    gVideoEvents = [];
  } else if (aKind == "audio") {
    gAudioEvents = [];
  }
}

function closeStream() {
  for (let stream of gStreams) {
    for (let track of stream.getTracks()) {
      track.stop();
    }
  }
  gStreams = [];
  gVideoEvents = [];
  gAudioEvents = [];
  message("closed");
}
</script>
</body>
</html>

Messung V0.5 in Prozent
C=100 H=100 G=100

¤ Dauer der Verarbeitung: 0.17 Sekunden  (vorverarbeitet am  2026-10-11) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

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.