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

iOS playback not working #10

Open
nixolas1 opened this issue Jan 21, 2020 · 3 comments · May be fixed by #14
Open

iOS playback not working #10

nixolas1 opened this issue Jan 21, 2020 · 3 comments · May be fixed by #14

Comments

@nixolas1
Copy link

Hi, we're having issues with playing video on iOS devices. We have tested on iPhone 7, X, and 11.
I read that hls.js dosn't support iOS, but that you can use a video element directly with an m3u8 source. It seems like that is being done here, but it still does not work. (Just a black/blank element)

Here is the element itself on an iPhone 11:
image

And here is our website with the sanity mux player: https://5e26f2b95a76c500071ec00d--ambassaden.netlify.com/

@nixolas1
Copy link
Author

We found this interesting info:

On iPhone,

from https://webkit.org/blog/6784/new-video-policies-for-ios/

Hacked in a playsinline attribute and seems to work on iOS!

mornir added a commit to mornir/sanity-mux-player that referenced this issue Nov 14, 2020
I used mux for a recent project and I thought I could provide some more information in this readme.
closes sanity-io#10 by adding a warning about the `playsinline` attribute. If I understand correctly, this attribute is not exposed and must be added programmatically?
@mornir mornir linked a pull request Nov 14, 2020 that will close this issue
@mornir
Copy link

mornir commented Nov 14, 2020

I was also quite confused by this. I thought there's something wrong about the hls.js library. The worst is that it's not the first time that I live this situation with missing playsinline attribute 😅

@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

Successfully merging a pull request may close this issue.

3 participants