Reputation: 601
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
Upvotes: 0
Views: 1050
Reputation: 601
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
Upvotes: 0
Reputation: 73065
Twilio developer evangelist here.
When you have MediaStreamTrack
objects, you can pass them directly to Video.connect
through the options. So, you can do something like this:
const stream = await navigator.mediaDevices.getUserMedia(constraints);
const room = await Video.connect(token, { tracks: stream.getTracks() })
This will turn your MediaStreamTrack
s into LocalTrack
s without you having to worry about it.
Let me know if that helps at all.
Upvotes: 1