Skip to content

Commit

Permalink
🐛 Issue #3: fix mediastream.js to pass unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
macdonst committed Oct 31, 2017
1 parent a0ca7c7 commit a3abcf0
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions www/mediastream.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/
var MediaStream = function (tracks) {
this.id = tracks.id;
this.active = false;
this.audioTracks = [];
if (tracks.audioTracks) {
this.audioTracks = tracks.audioTracks;
Expand All @@ -36,7 +37,6 @@ var MediaStream = function (tracks) {
}
this.onaddTrack = function () {};
this.onremoveTrack = function () {};
// this.active = true;
};

MediaStream.prototype.getAudioTracks = function () {
Expand Down Expand Up @@ -72,7 +72,6 @@ MediaStream.prototype.addTrack = function (trck) {
this.audioTracks = this.audioTracks.concat(trck);
this.onaddTrack();
}

};

MediaStream.prototype.removeTrack = function (trck) {
Expand All @@ -86,7 +85,6 @@ MediaStream.prototype.removeTrack = function (trck) {
return;
}
}

} else if (trck.kind === 'audio') {
tracks = this.audioTracks;
for (var j = 0; j < tracks.length; j++) {
Expand All @@ -96,11 +94,10 @@ MediaStream.prototype.removeTrack = function (trck) {
return;
}
}

}
};

MediaStream.prototype.getTrackbyId = function (id) {
MediaStream.prototype.getTrackById = function (id) {
var tracks = this.videoTracks.concat(this.audioTracks);
for (var i = 0; i < tracks.length; i++) {
if (tracks[i].id === id) {
Expand All @@ -116,8 +113,20 @@ MediaStream.prototype.clone = function () {
.toString(16)
.substring(1);
};
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
return (
s4() +
s4() +
'-' +
s4() +
'-' +
s4() +
'-' +
s4() +
'-' +
s4() +
s4() +
s4()
);
};

var video;
Expand Down

0 comments on commit a3abcf0

Please sign in to comment.