Skip to content
This repository has been archived by the owner on Oct 10, 2022. It is now read-only.

Add playsinline option #21

Open
j2is opened this issue Oct 24, 2021 · 1 comment
Open

Add playsinline option #21

j2is opened this issue Oct 24, 2021 · 1 comment

Comments

@j2is
Copy link

j2is commented Oct 24, 2021

Add a playsinline prop for autoplay on iOS

@AllanPooley
Copy link

This is the temporary fix I'm using 😢

videoRef.current.querySelector('video').setAttribute('playsinline', '')

const MuxVideo = (props) => {
  const { className, video } = props
  const styles = useStyles()
  const videoRef = useRef()
  useEffect(() => {
    if (videoRef.current) {
      videoRef.current.querySelector('video').setAttribute('playsinline', '')
    }
  }, [])
  if (!video?.video) return null
  return (
    <div className={cn(className || null, styles.videoContainer)} ref={videoRef}>
      <SanityMuxPlayer
        assetDocument={video.video}
        className={styles.video}
        autoload
        autoplay
        muted
        loop
        width='100%'
        showControls={false}
        poster
      />
    </div>
  )
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants