diff --git a/packages/hms-video-store/src/media/tracks/HMSLocalVideoTrack.ts b/packages/hms-video-store/src/media/tracks/HMSLocalVideoTrack.ts index 7d643c5a2f..aa7a208a23 100644 --- a/packages/hms-video-store/src/media/tracks/HMSLocalVideoTrack.ts +++ b/packages/hms-video-store/src/media/tracks/HMSLocalVideoTrack.ts @@ -261,10 +261,10 @@ export class HMSLocalVideoTrack extends HMSVideoTrack { */ async cleanup() { this.removeTrackEventListeners(this.nativeTrack); + await this.mediaStreamPluginsManager.cleanup(); + await this.pluginsManager.cleanup(); super.cleanup(); this.transceiver = undefined; - await this.pluginsManager.cleanup(); - await this.mediaStreamPluginsManager.cleanup(); this.processedTrack?.stop(); this.isPublished = false; if (isBrowser && isMobile()) { diff --git a/packages/hms-video-store/src/plugins/video/HMSMediaStreamPluginsManager.ts b/packages/hms-video-store/src/plugins/video/HMSMediaStreamPluginsManager.ts index 451050bf8f..5bc32bcfcf 100644 --- a/packages/hms-video-store/src/plugins/video/HMSMediaStreamPluginsManager.ts +++ b/packages/hms-video-store/src/plugins/video/HMSMediaStreamPluginsManager.ts @@ -65,6 +65,6 @@ export class HMSMediaStreamPluginsManager { } async cleanup() { - this.plugins.forEach(plugin => plugin.stop()); + this.removePlugins(Array.from(this.plugins)); } }