diff --git a/src/local-track.ts b/src/local-track.ts index 838e8e4..7fdddfc 100644 --- a/src/local-track.ts +++ b/src/local-track.ts @@ -4,6 +4,10 @@ import { Track } from './track'; * A wrapper around MediaStreamTrack. */ export class LocalTrack extends Track { + static Events = { + TrackUpdate: 'track-update', + }; + /** * Exchange the underlying track with a new track. Emit the `track-update` event to alert * listeners to an update on a new track. @@ -12,7 +16,7 @@ export class LocalTrack extends Track { * @fires LocalTrack#track-update */ replaceUnderlyingTrack(track: MediaStreamTrack): void { - this.emit('track-update', this.getUnderlyingTrack().id, track); + this.emit(LocalTrack.Events.TrackUpdate, this.getUnderlyingTrack().id, track); this.getUnderlyingTrack().stop(); this.setUnderlyingTrack(track); } diff --git a/src/peer-connection.ts b/src/peer-connection.ts index 9f8452d..7a8be40 100644 --- a/src/peer-connection.ts +++ b/src/peer-connection.ts @@ -29,7 +29,7 @@ class PeerConnection { * @listens LocalTrack#track-update */ addTrack(track: LocalTrack, ...streams: MediaStream[]): RTCRtpSender { - track.on('track-update', this.handleTrackUpdate); + track.on(LocalTrack.Events.TrackUpdate, this.handleTrackUpdate); return this.pc.addTrack(track.getUnderlyingTrack(), ...streams); }