This is the last sequence of code, all of the logs are returning correctly including the jquery log:
await webrtc.emit('consume', {
rtpCapabilities: device.rtpCapabilities,
roomId
}, async ({ params }) => {
if(params.error){
console.log("cannot consume")
return
}
console.log(params)
videoConsumer = await consumerTransport.consume({
id: params.videoId,
producerId: params.videoProducerId,
kind: 'video',
rtpParameters: params.videoRtpParameters
})
audioConsumer = await consumerTransport.consume({
id: params.audioId,
producerId: params.audioProducerId,
kind: 'audio',
rtpParameters: params.audioRtpParameters
})
const videoTrack = videoConsumer.track
const audioTrack = audioConsumer.track
console.log("Received consumers: ", videoConsumer, audioConsumer)
console.log("Tracks: ", videoTrack, audioTrack)
const remoteMediaStream = new MediaStream()
remoteMediaStream.addTrack(videoTrack)
remoteMediaStream.addTrack(audioTrack)
remoteVideoRef.current.srcObject = remoteMediaStream
// remoteVideoRef.current.play()
console.log("Remote reference: ", remoteVideoRef.current)
console.log("Remote video: ", remoteVideoRef.current.srcObject)
// setRemoteVideoObject(remoteMediaStream)
remoteVideoRef.current.onloadedmetadata = () => {
console.log('Video metadata loaded')
remoteVideoRef.current.play()
console.log("Jquery Data: ", $('#model-video')[0].srcObject, $('#model-video')[0].srcObject.getTracks())
}
remoteVideoRef.current.onerror = (error) => {
console.log('Video error:', error)
}
webrtc.emit('resume', ({ roomId }))
This is what is returned in the console but nothing is showing in the ui, it did appear once with no audio but when i refresh it goes away and didn’t return:
Jquery Data:
MediaStream {id: 'a270db7a-e544-449f-8cef-b737339d7bff', active: true, onaddtrack: null, onremovetrack: null, onactive: null, …}
(2) [MediaStreamTrack, MediaStreamTrack]
0
:
MediaStreamTrack {kind: 'audio', id: '0b6a7784-00b8-4fc7-b0cc-cc9ba92c41cd', label: '0b6a7784-00b8-4fc7-b0cc-cc9ba92c41cd', enabled: true, muted: false, …}
1
:
MediaStreamTrack {kind: 'video', id: 'c43972c0-b3a9-4721-9e63-1235229e943c', label: 'c43972c0-b3a9-4721-9e63-1235229e943c', enabled: true, muted: false, …}
length
:
2