当前位置: 首页 > news >正文

react-player静音不能自动播放问题

现象

移动端不能自动播放

原因

取决于您使用的浏览器,但muted如果您不想与autoplay用户交互,则必须使用视频。

Chrome 的自动播放策略很简单:

  • 始终允许静音自动播放
  • 在以下情况下允许自动播放声音:
    • 用户与域进行了交互(单击、点击等)。
    • 在桌面上,用户的媒体参与指数阈值已被超过,这意味着用户之前播放过有声视频。
    • 用户已将网站添加到移动设备的主屏幕或在桌面设备上安装 PWA。
  • 顶级框架可以将自动播放权限委托给其 iframe 以允许自动播放声音。

加了静音依旧不行

reactjs 使用react-player npm无法在IOS上自动播放视频

<ReactPlayer playing=true url="video_url" muted loop=true />

我认为您需要playsInline属性来实现iOS在非全屏模式下的自动播放

New <video> Policies for iOS | WebKit

官方说明的

A note about the playsinline attribute: this attribute has recently been added to the HTML specification, and WebKit has adopted this new attribute by unprefixing its legacy webkit-playsinline attribute. This legacy attribute has been supported since iPhoneOS 4.0, and accordance with our updated unprefixing policy, we’re pleased to have been able to unprefix webkit-playsinline. Unfortunately, this change did not make the cut-off for iOS 10 Developer Seed 2. If you would like to experiment with this new policy with iOS Developer Seed 2, the prefixed attribute will work, but we would encourage you to transition to the unprefixed attribute when support for it is available in a future seed.

加 playsinline 属性 和 muted属性

<ReactPlayer playing playsinline muted controls={false} url={earth} loop width="100%"height="100%"/>

http://www.lryc.cn/news/116192.html

相关文章:

  • 培训Java技术要多久才能学会?答案都在这里啦
  • Java中使用HttpPost发送form格式的请求
  • C语言----字节对齐
  • Next.js入门介绍(服务端渲染)
  • 模板Plus
  • spring事务和数据库事务是怎么实现
  • el-date-picker设置默认当前日期
  • vue中使用this.$refs获取不到子组件的方法,属性方法都为undefined的解决方法
  • Linux命令200例:df用于显示文件系统的磁盘空间使用情况
  • Service not registered 异常导致手机重启分析
  • 深度解读|一站式ABI平台 Smartbi Insight V11 能力再升级
  • vConsole手机调试模式uniapp和原生h5
  • Flutter Dart语言(05)异步
  • 滇医通微信小程序分析笔记
  • IoTDB在springboot2中的(二) 查询
  • SpringBoot 底层机制分析【Tomcat 启动+Spring 容器初始化+Tomcat 如何关联Spring 容器】【下】
  • NLP(六十五)LangChain中的重连(retry)机制
  • C字符串与C++ string 类:用法万字详解(上)
  • async/await函数需要trycatch吗?
  • Jenkins集成appium自动化测试(Windows篇)
  • MongoDB:切换log日志文件
  • 代码随想录第三十五天
  • 块、行内块水平垂直居中
  • Mybatis引出的一系列问题-动态 SQL
  • Docker学习之构建Base Image
  • SFM(Structure from Motion)和NeRF(Neural Radiance Fields)
  • [Vue] Vue2和Vue3的生命周期函数
  • springboot集成分布式任务调度系统xxl-job(调度器和执行器)
  • 11_Vue3中的新的组件
  • 详解推送Git分支时发生的 cannot lock ref 错误