Zemke / react-native-peerjs

PeerJS for React Native
56 stars 36 forks source link

Problem with mediaConnection.on ('stream') #6

Closed Ponao closed 4 years ago

Ponao commented 4 years ago

Here is my react-native code

privatePeer.on('call', call => {
        mediaDevices.getUserMedia({
            audio: true,
            video: true
            })
            .then(stream => {
               call.answer(stream)
            })

        call.on('error', console.log)

        call.on('stream', stream => {
            console.log(123)
        })
    })

Here is my web code

var getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia

    getUserMedia({video: true, audio: true}, (stream) => {
      let call = p.call(id, stream, options)

      call.on('stream', (remoteStream) => {
        console.log(123)
        var video = document.querySelector('video')

        if ('srcObject' in video) {
          video.srcObject = remoteStream
        } else {
          video.src = window.URL.createObjectURL(remoteStream) // for older browsers
        }

        video.play();
      })
      call.on('error', (err) => {
        console.log(err)
    })
    }, (err) => {

    })

The call.on ('stream') event does not fire in either the browser or react native

CryptishApps commented 4 years ago

Hey, did you ever fix this? I have the same issue.

Zemke commented 4 years ago

I heard reports that it's now working in 1.0.4. Please report back if that isn't the case.

Ponao commented 4 years ago

Hey, did you ever fix this? I have the same issue.

https://github.com/peers/peerjs/issues/612

Zemke commented 4 years ago

Sounds like what was done in https://github.com/Zemke/react-native-peerjs/pull/4.

Ponao commented 4 years ago

Sounds like what was done in #4.

Yes that's it

Zemke commented 4 years ago

Nice.