I would like to know the tracks presence in received stream onaddstream callback. Video calling is working well but I would like to make. audio only call, so I just passed audio:true,video:false in getUserMedia constraints, now when I receive stream I cant figure out tracks presence in stream.
How to know tracks presence in stream?
51 Answer
To Know presence of Audio and Video use getAudioTracks and getVideoTracks.
function checkStream(stream){ var hasMedia={hasVideo:false,hasAudio:false}; if(stream.getAudioTracks().length)// checking audio presence hasMedia.hasAudio=true; if(stream.getVideoTracks().length)// checking video presence hasMedia.hasVideo=true; return hasMedia; } To stop passing Video in stream change offer and answer constrinats.
constraints = { optional: [], mandatory: { OfferToReceiveAudio: true, OfferToReceiveVideo: false } }; 0