Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save webcat12345/6d1a7c587b87dffaa01cd06400e9fa45 to your computer and use it in GitHub Desktop.
Save webcat12345/6d1a7c587b87dffaa01cd06400e9fa45 to your computer and use it in GitHub Desktop.
Expect to get media stream from the Vidyo Client like Twilio does. Right now, I can not find a way to resolve this, so I am using native API. Need help on this.
// angular component init lifecycle
ngOnInit() {
// setup vidyo client
this.vidyoService.loadVidyoClientLibrary();
// as a seperate process, calling browser API to get media
navigator.getUserMedia({audio: true},
(stream) => {
this.mediaRecorder = new MediaStreamRecorder(stream);
this.mediaRecorder.audioChannels = 1;
this.mediaRecorder.mimeType = 'audio/wav'; // check this line for audio/wav
this.mediaRecorder.ondataavailable = (blob) => {
console.log('sent event');
this.mediaRecorder.stop();
this.readFromBlob(blob);
this.isRecording = false;
};
this.startRecord(stream);
}, (error) => {
console.log(error);
});
}
// Twilio handle tracks in this way
// Twilio SDK returns LocalAudioTrack through the client, (I guess this track will be sent to other participants)
let audioTrack = await Video.createLocalAudioTrack(); // Video comes from the Twilio SDK.
// We can extract audio context from this LocalAudioTrack
async startTwilio() {
// check devices
this.tracks = await this.twilioService.checkDevices(); // will call above function to create local media tracks, Video, Audio
if (this.tracks.localAudioTrack) {
const mediaStream = new MediaStream([this.tracks.localAudioTrack.mediaStreamTrack]);
this.mediaRecorder = new MediaStreamRecorder(mediaStream);
this.mediaRecorder.audioChannels = 1;
this.mediaRecorder.mimeType = 'audio/wav'; // check this line for audio/wav
// ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment