Organize events (#13)
* move internal events & remove unused events * `TrackUnpublishedEvent` for local tracks * update example since we have local track unpublish events * use flutter_webrtc 0.6.9
This commit is contained in:
@@ -151,14 +151,11 @@ class LocalParticipant extends Participant {
|
||||
|
||||
/// Unpublish a track that's already published
|
||||
@override
|
||||
Future<void> unpublishTrack(String trackSid, {bool notify = false}) async {
|
||||
Future<void> unpublishTrack(String trackSid, {bool notify = true}) async {
|
||||
logger.finer('Unpublish track sid: $trackSid, notify: $notify');
|
||||
final pub = trackPublications.remove(trackSid);
|
||||
if (pub is! LocalTrackPublication) return;
|
||||
|
||||
// final existing = tracks.values.where((element) => element.track == track);
|
||||
// if (existing.isEmpty) return;
|
||||
// final pub = existing.first;
|
||||
final track = pub.track;
|
||||
if (track != null) {
|
||||
await track.stop();
|
||||
@@ -178,6 +175,13 @@ class LocalParticipant extends Participant {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (notify) {
|
||||
[events, roomEvents].emit(TrackUnpublishedEvent(
|
||||
participant: this,
|
||||
publication: pub,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// Publish a new data payload to the room.
|
||||
|
||||
@@ -152,7 +152,7 @@ class RemoteParticipant extends Participant {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> unpublishTrack(String trackSid, {bool notify = false}) async {
|
||||
Future<void> unpublishTrack(String trackSid, {bool notify = true}) async {
|
||||
logger.finer('Unpublish track sid: $trackSid, notify: $notify');
|
||||
final pub = trackPublications.remove(trackSid);
|
||||
if (pub is! RemoteTrackPublication) return;
|
||||
@@ -166,10 +166,6 @@ class RemoteParticipant extends Participant {
|
||||
track: track,
|
||||
publication: pub,
|
||||
));
|
||||
|
||||
// if (track is AudioTrack) {
|
||||
// await AudioManager().decrementSubscriptionCounter();
|
||||
// }
|
||||
}
|
||||
|
||||
if (notify) {
|
||||
|
||||
Reference in New Issue
Block a user