Skip to content

Commit 6b41dc1

Browse files
committed
fix(copy): support copying MediaStream object
use MediaStream clone method to clone mediastream object Closes angular#16055
1 parent e58bcfa commit 6b41dc1

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/Angular.js

+3
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,9 @@ function copy(source, destination, maxDepth) {
10051005

10061006
case '[object Blob]':
10071007
return new source.constructor([source], {type: source.type});
1008+
1009+
case '[object MediaStream]':
1010+
return source.clone();
10081011
}
10091012

10101013
if (isFunction(source.cloneNode)) {

test/AngularSpec.js

+7
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,13 @@ describe('angular', function() {
603603
/* eslint-enable */
604604
});
605605

606+
it('should copy media stream objects', function() {
607+
window.getUserMedia({video:true, audio:false}, function(stream) {
608+
var streamCopy = copy(stream);
609+
expect(streamCopy).toEqual(stream);
610+
});
611+
});
612+
606613
it('should copy source until reaching a given max depth', function() {
607614
var source = {a1: 1, b1: {b2: {b3: 1}}, c1: [1, {c2: 1}], d1: {d2: 1}};
608615
var dest;

0 commit comments

Comments
 (0)