Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

202
Visualizações
What to do to store recording stream into the mobile browser using Media Recorder API?

I have a project requirement to record and store the currently running video stream. I have used webRTC for video streaming, and to record the video streaming, I have used MediaRecorder API. It is completely working fine in the desktop system. But it is not working in the mobile browser.

Any idea why it is not working in the mobile browser?

Following is the code snippet:

componentDidMount = async () => {
                recordingStream =  await navigator.mediaDevices.getDisplayMedia({
                  video: true,
                  audio: true,
                });

                const mergedAudio = await this.mergeAudioStreams();
                console.log("audio track length... ", mergedAudio.length);
                const tracks = [
                  ...recordingStream.getVideoTracks(),
                  ...mergedAudio,
                ];

                captureStream = new MediaStream(tracks);
                mediaRecorder = new MediaRecorder(captureStream, options);
                mediaRecorder.ondataavailable = this.handleDataAvailable;
                mediaRecorder.start();
       
}

handleDataAvailable = async event => {
    console.log("data-available", event);
    if (event.data.size > 0) {
      recordedChunks.push(event.data);
      this.download();
    } else {
      // ...
      console.log("in else");
    }
  };
  
 download = async () => {
    console.log("in download fn");
    var blob = await new Blob(recordedChunks, {
      type: "video/mp4",
    });
    
    
    //called the API to store the recorded video
}

mergeAudioStreams = async () => {
console.log("recordScreen fn called");

const ctx = new AudioContext();
const dest = ctx.createMediaStreamDestination();
let localSource, remoteSource;

if (this.state.localStream.getAudioTracks().length > 0) {
  localSource = ctx.createMediaStreamSource(this.state.localStream);
}

if (this.state.selectedVideo.stream.getAudioTracks().length > 0) {
  remoteSource = ctx.createMediaStreamSource(
    this.state.selectedVideo.stream
  );
}

const localGain = ctx.createGain();
const remoteGain = ctx.createGain();

localGain.gain.value = 0.7;
remoteGain.gain.value = 0.7;

localSource.connect(localGain).connect(dest);

remoteSource.connect(remoteGain).connect(dest);

console.log("combine tracks..", dest.stream.getAudioTracks());

return dest.stream.getAudioTracks();
  };

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda