livekit-client
Advanced tools
Comparing version 0.3.2 to 0.3.3
@@ -7,2 +7,3 @@ export declare enum RoomEvent { | ||
TrackSubscribed = "trackSubscribed", | ||
TrackSubscriptionFailed = "trackSubscriptionFailed", | ||
TrackUnpublished = "trackUnpublished", | ||
@@ -18,2 +19,3 @@ TrackUnsubscribed = "trackUnsubscribed", | ||
TrackSubscribed = "trackSubscribed", | ||
TrackSubscriptionFailed = "trackSubscriptionFailed", | ||
TrackUnpublished = "trackUnpublished", | ||
@@ -20,0 +22,0 @@ TrackUnsubscribed = "trackUnsubscribed", |
@@ -11,2 +11,3 @@ "use strict"; | ||
RoomEvent["TrackSubscribed"] = "trackSubscribed"; | ||
RoomEvent["TrackSubscriptionFailed"] = "trackSubscriptionFailed"; | ||
RoomEvent["TrackUnpublished"] = "trackUnpublished"; | ||
@@ -23,2 +24,3 @@ RoomEvent["TrackUnsubscribed"] = "trackUnsubscribed"; | ||
ParticipantEvent["TrackSubscribed"] = "trackSubscribed"; | ||
ParticipantEvent["TrackSubscriptionFailed"] = "trackSubscriptionFailed"; | ||
ParticipantEvent["TrackUnpublished"] = "trackUnpublished"; | ||
@@ -25,0 +27,0 @@ ParticipantEvent["TrackUnsubscribed"] = "trackUnsubscribed"; |
@@ -10,3 +10,3 @@ import { ParticipantInfo } from '../../proto/model'; | ||
constructor(id: string, name?: string); | ||
addSubscribedMediaTrack(mediaTrack: MediaStreamTrack, sid: Track.SID): RemoteTrackPublication | undefined; | ||
addSubscribedMediaTrack(mediaTrack: MediaStreamTrack, sid: Track.SID, triesLeft?: number): RemoteTrackPublication | undefined; | ||
addSubscribedDataTrack(dataChannel: RTCDataChannel, sid: Track.SID, name: string): RemoteTrackPublication; | ||
@@ -13,0 +13,0 @@ get hasMetadata(): boolean; |
@@ -27,19 +27,4 @@ "use strict"; | ||
} | ||
addSubscribedMediaTrack(mediaTrack, sid) { | ||
const isVideo = mediaTrack.kind === 'video'; | ||
let track; | ||
if (isVideo) { | ||
track = new RemoteVideoTrack_1.RemoteVideoTrack(mediaTrack, sid); | ||
} | ||
else { | ||
track = new RemoteAudioTrack_1.RemoteAudioTrack(mediaTrack, sid); | ||
} | ||
if (!this.hasMetadata) { | ||
// try this again later | ||
setTimeout(() => { | ||
this.addSubscribedMediaTrack(mediaTrack, sid); | ||
}, 100); | ||
return; | ||
} | ||
// find the track publication or create one | ||
addSubscribedMediaTrack(mediaTrack, sid, triesLeft) { | ||
// find the track publication | ||
// it's possible for the media track to arrive before participant info | ||
@@ -59,6 +44,25 @@ let publication = this.getTrackPublication(sid); | ||
} | ||
// when we couldn't locate the track, it's possible that the metadata hasn't | ||
// yet arrived. Wait a bit longer for it to arrive, or fire an error | ||
if (!publication) { | ||
loglevel_1.default.error('could not find published track', this.sid, sid); | ||
if (triesLeft === 0) { | ||
loglevel_1.default.error('could not find published track', this.sid, sid); | ||
this.emit(events_1.ParticipantEvent.TrackSubscriptionFailed, sid); | ||
return; | ||
} | ||
if (triesLeft === undefined) | ||
triesLeft = 20; | ||
setTimeout(() => { | ||
this.addSubscribedMediaTrack(mediaTrack, sid, triesLeft - 1); | ||
}, 150); | ||
return; | ||
} | ||
const isVideo = mediaTrack.kind === 'video'; | ||
let track; | ||
if (isVideo) { | ||
track = new RemoteVideoTrack_1.RemoteVideoTrack(mediaTrack, sid); | ||
} | ||
else { | ||
track = new RemoteAudioTrack_1.RemoteAudioTrack(mediaTrack, sid); | ||
} | ||
publication.track = track; | ||
@@ -65,0 +69,0 @@ // set track name etc |
@@ -208,2 +208,5 @@ "use strict"; | ||
}); | ||
participant.on(events_2.ParticipantEvent.TrackSubscriptionFailed, (sid) => { | ||
this.emit(events_2.RoomEvent.TrackSubscriptionFailed, sid, participant); | ||
}); | ||
} | ||
@@ -210,0 +213,0 @@ return participant; |
@@ -1,2 +0,2 @@ | ||
declare const version = "0.3.2"; | ||
declare const version = "0.3.3"; | ||
export { version }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = void 0; | ||
const version = '0.3.2'; | ||
const version = '0.3.3'; | ||
exports.version = version; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "livekit-client", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "JavaScript/TypeScript client SDK for LiveKit", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
315365
4942