Skip to content

Commit b1bb4cb

Browse files
authored
Merge pull request #492 from cordova-rtc/bugs/MediaEventListener
Bugs/media event listener
2 parents b13fbd0 + 2c1553a commit b1bb4cb

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

dist/cordova-plugin-iosrtc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ var EventTarget = function () {
7575
EventTarget.prototype = Object.create(YaetiEventTarget.prototype);
7676
EventTarget.prototype.constructor = EventTarget;
7777

78+
Object.defineProperties(EventTarget.prototype, Object.getOwnPropertyDescriptors(YaetiEventTarget.prototype));
79+
7880
EventTarget.prototype.dispatchEvent = function (event) {
7981

8082
Object.defineProperty(event, 'target', {
@@ -403,6 +405,8 @@ MediaStream.prototype.addTrack = function (track) {
403405
addListenerForTrackEnded.call(this, track);
404406

405407
exec(null, null, 'iosrtcPlugin', 'MediaStream_addTrack', [this.id, track.id]);
408+
409+
this.dispatchEvent(new Event('update'));
406410
};
407411

408412

@@ -427,6 +431,8 @@ MediaStream.prototype.removeTrack = function (track) {
427431

428432
exec(null, null, 'iosrtcPlugin', 'MediaStream_removeTrack', [this.id, track.id]);
429433

434+
this.dispatchEvent(new Event('update'));
435+
430436
checkActive.call(this);
431437
};
432438

js/EventTarget.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ var EventTarget = function () {
1111
EventTarget.prototype = Object.create(YaetiEventTarget.prototype);
1212
EventTarget.prototype.constructor = EventTarget;
1313

14+
Object.defineProperties(EventTarget.prototype, Object.getOwnPropertyDescriptors(YaetiEventTarget.prototype));
15+
1416
EventTarget.prototype.dispatchEvent = function (event) {
1517

1618
Object.defineProperty(event, 'target', {

js/MediaStream.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ MediaStream.prototype.addTrack = function (track) {
277277
addListenerForTrackEnded.call(this, track);
278278

279279
exec(null, null, 'iosrtcPlugin', 'MediaStream_addTrack', [this.id, track.id]);
280+
281+
this.dispatchEvent(new Event('update'));
280282
};
281283

282284

@@ -301,6 +303,8 @@ MediaStream.prototype.removeTrack = function (track) {
301303

302304
exec(null, null, 'iosrtcPlugin', 'MediaStream_removeTrack', [this.id, track.id]);
303305

306+
this.dispatchEvent(new Event('update'));
307+
304308
checkActive.call(this);
305309
};
306310

0 commit comments

Comments
 (0)