Skip to content

Commit

Permalink
Fixed deprecated codes in the MultiStreamsMixer.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
muaz-khan committed Jan 14, 2019
1 parent d5174dc commit 580f967
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion MultiStreamsMixer.js
@@ -1,4 +1,4 @@
// Last time updated: 2018-12-22 9:13:29 AM UTC
// Last time updated: 2019-01-12 7:02:57 AM UTC

// ________________________
// MultiStreamsMixer v1.0.7
Expand Down
2 changes: 1 addition & 1 deletion MultiStreamsMixer.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 23 additions & 13 deletions MultiStreamsMixer.ts
@@ -1,9 +1,5 @@
/**
* @Author: maalouf
* @Date: 2019-01-04T10:14:45+01:00
* @Last modified by: maalouf
* @Last modified time: 2019-01-04T14:53:20+01:00
*/
// @maalouf

export class MultiStreamsMixer {

videos : Array<any>;
Expand Down Expand Up @@ -42,7 +38,9 @@ export class MultiStreamsMixer {

private isPureAudio(){
for (let i = 0; i < this.arrayOfMediaStreams.length;i++){
if (this.arrayOfMediaStreams[i].getVideoTracks().length > 0) return false;
if (this.arrayOfMediaStreams[i].getTracks().filter(function(t) {
return t.kind === 'video';
}).length > 0) return false;
}
return true;
}
Expand Down Expand Up @@ -200,7 +198,9 @@ export class MultiStreamsMixer {
return mixedAudioStream;
} else {
if (mixedAudioStream) {
mixedAudioStream.getAudioTracks().forEach(track => {
mixedAudioStream.getTracks().filter(function(t) {
return t.kind === 'audio';
}).forEach(track => {
mixedVideoStream.addTrack(track);
});
}
Expand All @@ -212,7 +212,9 @@ export class MultiStreamsMixer {
this.resetVideoStreams();
var capturedStream = this.canvas.captureStream() || this.canvas.mozCaptureStream();
var videoStream = new MediaStream();
capturedStream.getVideoTracks().forEach(track => {
capturedStream.getTracks().filter(function(t) {
return t.kind === 'video';
}).forEach(track => {
videoStream.addTrack(track);
});
this.canvas.stream = videoStream;
Expand All @@ -231,7 +233,9 @@ export class MultiStreamsMixer {

let audioTracksLength = 0;
this.arrayOfMediaStreams.forEach(stream => {
if (!stream.getAudioTracks().length) {
if (!stream.getTracks().filter(function(t) {
return t.kind === 'audio';
}).length) {
return;
}
audioTracksLength++;
Expand Down Expand Up @@ -274,13 +278,17 @@ export class MultiStreamsMixer {

this.arrayOfMediaStreams.concat(streams);
streams.forEach(stream => {
if (stream.getVideoTracks().length) {
if (stream.getTracks().filter(function(t) {
return t.kind === 'video';
}).length) {
var video = this.getVideo(stream);
video['stream'] = stream;
this.videos.push(video);
}

if (stream.getAudioTracks().length && this.audioContext) {
if (stream.getTracks().filter(function(t) {
return t.kind === 'audio';
}).length && this.audioContext) {
var audioSource = this.audioContext.createMediaStreamSource(stream);
audioSource.connect(this.audioDestination);
this.audioSources.push(audioSource);
Expand Down Expand Up @@ -337,7 +345,9 @@ export class MultiStreamsMixer {

// via: @adrian-ber
streams.forEach(stream => {
if (!stream.getVideoTracks().length) {
if (!stream.getTracks().filter(function(t) {
return t.kind === 'video';
}).length) {
return;
}
let tempVideo = this.getVideo(stream);
Expand Down

0 comments on commit 580f967

Please sign in to comment.