Skip to content

Commit

Permalink
Merge pull request #492 from cordova-rtc/bugs/MediaEventListener
Browse files Browse the repository at this point in the history
Bugs/media event listener
  • Loading branch information
hthetiot authored Apr 29, 2020
2 parents b13fbd0 + 2c1553a commit b1bb4cb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dist/cordova-plugin-iosrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ var EventTarget = function () {
EventTarget.prototype = Object.create(YaetiEventTarget.prototype);
EventTarget.prototype.constructor = EventTarget;

Object.defineProperties(EventTarget.prototype, Object.getOwnPropertyDescriptors(YaetiEventTarget.prototype));

EventTarget.prototype.dispatchEvent = function (event) {

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

exec(null, null, 'iosrtcPlugin', 'MediaStream_addTrack', [this.id, track.id]);

this.dispatchEvent(new Event('update'));
};


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

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

this.dispatchEvent(new Event('update'));

checkActive.call(this);
};

Expand Down
2 changes: 2 additions & 0 deletions js/EventTarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ var EventTarget = function () {
EventTarget.prototype = Object.create(YaetiEventTarget.prototype);
EventTarget.prototype.constructor = EventTarget;

Object.defineProperties(EventTarget.prototype, Object.getOwnPropertyDescriptors(YaetiEventTarget.prototype));

EventTarget.prototype.dispatchEvent = function (event) {

Object.defineProperty(event, 'target', {
Expand Down
4 changes: 4 additions & 0 deletions js/MediaStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ MediaStream.prototype.addTrack = function (track) {
addListenerForTrackEnded.call(this, track);

exec(null, null, 'iosrtcPlugin', 'MediaStream_addTrack', [this.id, track.id]);

this.dispatchEvent(new Event('update'));
};


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

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

this.dispatchEvent(new Event('update'));

checkActive.call(this);
};

Expand Down

0 comments on commit b1bb4cb

Please sign in to comment.