Search code examples
cordovatwiliowebrtccordova-pluginstwilio-video

Twilio Video MediaStreamTrack TypeError with Cordova


I’m developing a video live streaming app with Cordova using Twilio video conferencing. I’m trying to stream video from the device front-facing camera. It works well Android but I'm facing some issues on iOS.

I’m using a cordova-plugin-iosrtc plugin to expose the navigator.mediaDevices API

on the connect method I get this error

TypeError: track must be a LocalAudioTrack, LocalVideoTrack, LocalDataTrack, orMediaStreamTrack

I changed the code to the required track type

const { LocalAudioTrack, LocalVideoTrack, connect } = require('twilio-video');

constmediaStream = awaitnavigator.mediaDevices.getUserMedia(constraints); 

const tracks = mediaStream.getTracks().map(track => track.kind === 'audio' ? newLocalAudioTrack(track) :newLocalVideoTrack(track)); const room = awaitconnect('token', { tracks }); 

and I get this error after the change

TypeError: Argument 1 ('track') to mediaStream.addTrack must be an instance of MediaStreamTrack and sometimes this one => typeError undefined isn't an object (evaluating 'tracks.id')

Thanks In Advance I appreciate any kind of help


Solution

  • Cordova IOS compiled version doesn't stream the same media stream track types as same as Safari does on Web, I switched to Capacitor.js and worked with its plugins but still, that didn't work with me.

    As far as this issue it will not work with Cordova cordova-plugin-iosrtc and we postponed this feature in our app