feross / simple-peer

📡 Simple WebRTC video, voice, and data channels
MIT License
7.44k stars 975 forks source link

Audio only connection doesn't work #884

Closed pjebs closed 2 years ago

pjebs commented 2 years ago

It appears and audio only connection doesn't transit audio.: navigator.mediaDevices.getUserMedia({audio: true, video: false}).then(gotMedia).catch((err) => {console.log(err)});

The moment I make video: true and then add:

        p.on('stream', stream => {
          var video = document.querySelector('video')
          if ('srcObject' in video) {
            video.srcObject = stream
          } else {
            video.src = window.URL.createObjectURL(stream)
          }
          video.play()
        })
    }

...
<video width="320" height="240" controls></video>

Audio and Video then work.

pjebs commented 2 years ago

It works now:



        p.on('stream', stream => {
          var audio = document.querySelector('audio')
          if ('srcObject' in audio) {
            audio.srcObject = stream
          } else {
            audio.src = window.URL.createObjectURL(stream)
          }
          audio.play()
        })

...
<audio controls>

</audio>