Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/useDisplayMedia.md
1---2category: Sensors3related: useUserMedia4---56# useDisplayMedia78Reactive [`mediaDevices.getDisplayMedia`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia) streaming.910## Usage1112```vue13<script setup lang="ts">14import { useDisplayMedia } from '@vueuse/core'15import { useTemplateRef } from 'vue'1617const { stream, start } = useDisplayMedia()1819// start streaming20start()2122const videoRef = useTemplateRef('video')23watchEffect(() => {24// preview on a video element25videoRef.value.srcObject = stream.value26})27</script>2829<template>30<video ref="video" />31</template>32```3334## Type Declarations3536```ts37export interface UseDisplayMediaOptions extends ConfigurableNavigator {38/**39* If the stream is enabled40* @default false41*/42enabled?: MaybeRef<boolean>43/**44* If the stream video media constraints45*/46video?: boolean | MediaTrackConstraints | undefined47/**48* If the stream audio media constraints49*/50audio?: boolean | MediaTrackConstraints | undefined51}52export interface UseDisplayMediaReturn extends Supportable {53stream: ShallowRef<MediaStream | undefined>54start: () => Promise<MediaStream | undefined>55stop: () => void56enabled: ShallowRef<boolean>57}58/**59* Reactive `mediaDevices.getDisplayMedia` streaming60*61* @see https://vueuse.org/useDisplayMedia62* @param options63*/64export declare function useDisplayMedia(65options?: UseDisplayMediaOptions,66): UseDisplayMediaReturn67```68