From 6d44d9bc56423989dbc948573dcfe786e316f470 Mon Sep 17 00:00:00 2001 From: Waleed Khaled Date: Tue, 20 Feb 2024 13:28:28 +0400 Subject: [PATCH] fix(useUserMedia): stop stream on scope dispose (#3757) --- packages/core/useUserMedia/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/core/useUserMedia/index.ts b/packages/core/useUserMedia/index.ts index def44ed92f7..39b60467cf6 100644 --- a/packages/core/useUserMedia/index.ts +++ b/packages/core/useUserMedia/index.ts @@ -1,6 +1,6 @@ /* this implementation is original ported from https://github.com/logaretm/vue-use-web by Abdelrahman Awad */ -import type { MaybeRef } from '@vueuse/shared' +import { type MaybeRef, tryOnScopeDispose } from '@vueuse/shared' import type { Ref } from 'vue-demi' import { ref, shallowRef, watch } from 'vue-demi' import { useSupported } from '../useSupported' @@ -109,6 +109,10 @@ export function useUserMedia(options: UseUserMediaOptions = {}) { { immediate: true }, ) + tryOnScopeDispose(() => { + stop() + }) + return { isSupported, stream,