YouTube在手机上嵌入自动播放 [英] Youtube embed autoplay on mobile

查看:236
本文介绍了YouTube在手机上嵌入自动播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用React将页面上的youtube视频设置为正确的iframe.一切正常,但手机无法自动播放选项.

I use React to set iframe with youtube video on page in correct size. All works well but for mobiles doesn't work autoplay option.

页面有趣之处在于,作为示例视频,它非常完美.

What is interesting for page, what I have as example video it works perfect.

<iframe type="text/html"  allowTransparency="true"  height="100%" width="100%" preload="metadata" gesture="media" allow="encrypted-media" className="autoplay-iframe"
            src={`https://www.youtube.com/embed/`+this.props.autoplay+`?autoplay=1&version=3&html5=1&hd=1&controls=0&loop=1&playlist=`+this.props.autoplay+`&playsinline=1&rel=0&showinfo=0&modestbranding=1&related=0&enablejsapi=1&origin=`+window.location.hostname} frameborder="0"></iframe>

上面是我的iframe代码. 我削减了iframe代码的一部分,但是styles属性中只有样式.自动播放并不重要. 其他页面的最终URL相同.我不知道为什么.有什么提示可以解决这个问题吗?

above is my iframe code. I cut some part of iframe code but there are just style in styles attribute. It isn't important for autoplay. The same finally url for other page works. I'm not sure why. Any hints how I can solve this problem?

谢谢.

推荐答案

您将无法实现此功能,因为有意将其禁止所有移动设备使用.原因是用户保存蜂窝数据. 此帖子.

You will not be able to implement this, since it is intentionally disabled to all mobile devices. The reason is for the user to save cellular data. It is also cited in this post.

无法自动播放视频的原因很简单.该功能是 在两个iOS中故意已禁用和适用于移动设备的Android. 这样做的原因是为了节省移动用户的钱.此类设备 (尤其是手机)通常使用通过以下方式收费的数据连接: 带宽.他们有数据限制,超过结果要付费.

The reason that video autoplay doesn’t work is simple. The feature is deliberately disabled in both iOS and Android for mobile devices. The reason this is done is to save mobile users money. Such devices (especially mobile phones) often use data connections that charge by bandwidth. They have data limits and going over results in a fee.

以下SO帖子也支持此语句.

This statement was also supported with the following SO post.

  • no autoplay in iframe HTML5 player on mobile (Android Chrome and Firefox)?
  • how to get embedded youtube video to autostart on iphone
  • Youtube autoplay not working on mobile devices with embedded HTML5 player

这篇关于YouTube在手机上嵌入自动播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆