Skip to content

Commit

Permalink
fix(useUserMedia): stop stream on scope dispose (#3757)
Browse files Browse the repository at this point in the history
  • Loading branch information
Waleed-KH committed Feb 20, 2024
1 parent b3d7400 commit 6d44d9b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion 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'
Expand Down Expand Up @@ -109,6 +109,10 @@ export function useUserMedia(options: UseUserMediaOptions = {}) {
{ immediate: true },
)

tryOnScopeDispose(() => {
stop()
})

return {
isSupported,
stream,
Expand Down

0 comments on commit 6d44d9b

Please sign in to comment.