Skip to content

Commit

Permalink
fix(useMediaControls): apply state when target ref changes (#2999)
Browse files Browse the repository at this point in the history
  • Loading branch information
ferferga committed Apr 19, 2023
1 parent 8f6a0c5 commit b20aacf
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/core/useMediaControls/index.ts
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

0 comments on commit b20aacf

Please sign in to comment.