使用React Player NPM无法在IOS上自动播放视频 [英] Video is not auto playing on IOS by using react-player npm
问题描述
我想在用户访问页面时播放视频,它在IOS以外的所有平台上都可以正常工作. 我正在使用反应播放器 npm.我已经尝试通过传递静音属性,但是不起作用.
I want to play video when user comes to the page, it is working fine for all the platform except IOS. I am using react-player npm. I have tried by passing muted property but doesn't work.
我的代码如下
<ReactPlayer playing=true url="video_url" muted loop=true />
提前谢谢!
推荐答案
I think you need the playsinline
attribute for iOS autoplaying in non-fullscreen, as per https://webkit.org/blog/6784/new-video-policies-for-ios/:
在iPhone上,现在将允许元素内联播放,并且在开始播放时不会自动进入全屏模式. 没有playinline属性的元素将继续需要全屏模式才能在iPhone上播放.
On iPhone, elements will now be allowed to play inline, and will not automatically enter fullscreen mode when playback begins. elements without playsinline attributes will continue to require fullscreen mode for playback on iPhone.
react-player
支持它作为道具.
这篇关于使用React Player NPM无法在IOS上自动播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!