This message was deleted.
# helpdesk
s
This message was deleted.
l
what is not working with this code
s
videoElm
is not playing audio/video.
l
remove autoplay from video element and enable controls and see if you can play the video manually
s
it's keep loading
l
on what event are you running this piece of code
s
It's inside
renderParticipant
function which is being called from almost every event. By the why on which event it should be called?
l
you get handle to tracks on
trackPublished
event
or maybe you can do it on
trackSubscribed
event.
s
let me double check.
yeah it's being called from those events. One odd behaviour, If I use like
videoElm.srcObject = new MediaStream([videoStream, audioStream]);
It's not displaying the video. but if I change it like
cameraPub?.videoTrack?.attach(videoElm);
It works but it's only video. There isn't any audio.
l
you need attach audioTrack to audio element
s
yeah, that's the point. In that case there will be two htmlElements, that's why I am looking for a way to combine the audio/video track into single MediaStream so that it can be attach with one htmlElement.
l
is there any reason you just want one html element for both tracks ?
s
In my use-case, I have list of VOD (videoJS)+Live Streams (SLDP)+Live Streams (WebRTC). VOD (videoJS)+Live Streams (SLDP) creates only single video htmlElement, and based on this logic all the required features are implemented. So in-case of Live Streams (WebRTC) If it creates two HtmlElements, existing features needs to re-write and re-tested. Just wanted to avoid that.
l
hmm. in that case, what you've tried is the right way but don't know whats causing the issue
can you try
videoElm.srcObject = new MediaStream([videoStream]);
and see if only video loads properly using this method
s
videoElm.srcObject = new MediaStream([cameraPub.videoTrack.mediaStreamTrack]);
No luck. 🙂
oh, This one works. 🙂
Copy code
cameraPub?.videoTrack?.attach(videoElm);
micPub?.audioTrack?.attach(videoElm);
👍 1
l
thats great
but there might be a catch also. sometimes video autoplay is blocked if its not muted. Just take care of that
🫡 1