Skip to content

Commit c8e8438

Browse files
authored
Fire event on track restart (#511)
* Fire event on track restart * Add changeset
1 parent cb67610 commit c8e8438

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

.changeset/happy-olives-lay.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'livekit-client': patch
3+
---
4+
5+
Track event for track restart

src/room/events.ts

+4
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,10 @@ export enum TrackEvent {
427427
Message = 'message',
428428
Muted = 'muted',
429429
Unmuted = 'unmuted',
430+
/**
431+
* Only fires on LocalTracks
432+
*/
433+
Restarted = 'restarted',
430434
Ended = 'ended',
431435
Subscribed = 'subscribed',
432436
Unsubscribed = 'unsubscribed',

src/room/track/LocalTrack.ts

+1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ export default abstract class LocalTrack extends Track {
183183

184184
this.mediaStream = mediaStream;
185185
this.constraints = constraints;
186+
this.emit(TrackEvent.Restarted, this);
186187
return this;
187188
}
188189

src/room/track/Track.ts

+1
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ export type TrackEventCallbacks = {
398398
message: () => void;
399399
muted: (track?: any) => void;
400400
unmuted: (track?: any) => void;
401+
restarted: (track?: any) => void;
401402
ended: (track?: any) => void;
402403
updateSettings: () => void;
403404
updateSubscription: () => void;

0 commit comments

Comments
 (0)