Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(useMediaControls): apply state when target ref changes #2999

Merged
merged 1 commit into from
Apr 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/core/useMediaControls/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,30 +293,30 @@ export function useMediaControls(target: MaybeRef<HTMLMediaElement | null | unde
})

/**
* Watch volume and change player volume when volume prop changes
* Apply composable state to the element, also when element is changed
*/
watch(volume, (vol) => {
watch([target, volume], () => {
const el = toValue(target)
if (!el)
return

el.volume = vol
el.volume = volume.value
})

watch(muted, (mute) => {
watch([target, muted], () => {
const el = toValue(target)
if (!el)
return

el.muted = mute
el.muted = muted.value
})

watch(rate, (rate) => {
watch([target, rate], () => {
const el = toValue(target)
if (!el)
return

el.playbackRate = rate
el.playbackRate = rate.value
})

/**
Expand Down