美文网首页
webrtc 屏幕共享时添加声音

webrtc 屏幕共享时添加声音

作者: hijiang | 来源:发表于2020-02-13 22:34 被阅读0次
    navigator.getUserMedia = navigator.mozGetUserMedia || navigator.webkitGetUserMedia;
      navigator.getUserMedia(screen_constraints, function (stream) {
        navigator.getUserMedia({audio: true}, function (audioStream) {
          stream.addTrack(audioStream.getAudioTracks()[0]);
          var mediaRecorder = new MediaStreamRecorder(stream);
          mediaRecorder.mimeType = 'video/mp4'
          mediaRecorder.stream = stream;
    
          document.querySelector('video').src = URL.createObjectURL(stream);
          var video =  document.getElementById('screen-video')
          if (video) {
            video.src = URL.createObjectURL(stream);
            video.width = 360;
            video.height = 300;
          }
        }, function (error) {
          alert(error);
        });
      }, function (error) {
        alert(error);
      });
    });
    

    相关文章

      网友评论

          本文标题:webrtc 屏幕共享时添加声音

          本文链接:https://www.haomeiwen.com/subject/shdrfhtx.html