移动设备中的html5自动播放视频 [英] html5 autoplay video in Mobile device

查看:128
本文介绍了移动设备中的html5自动播放视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在移动设备上打开网址时,如果没有静音属性,则自动播放功能无法正常工作。如何在不使用静音属性的情况下播放视频?我需要在没有点击静音按钮的情况下进行音量调整,还有一件更重要的事情是,所有内容都将在没有 JS和Jquery 的情况下运行。

Auto play is not working without muted attribute, when I try to open url in mobile device. How to play video without using muted attribute ? I need to volume without click on muted button and one more important thing is that all thing will be working without JS and Jquery.

推荐答案

您无法在iOS中实现此操作而无需黑客入侵。从官方的Apple WebKit文档:

You wont be able to achieve this in iOS without hacks. From the official Apple WebKit documentation:


从iOS 10开始,WebKit将其内联和自动播放策略放宽到
,使这些演示成为可能,但仍然记住网站的
带宽和用户的电池。

Starting in iOS 10, WebKit relaxes its inline and autoplay policies to make these presentations possible, but still keeps in mind sites’ bandwidth and users’ batteries.

默认情况下,WebKit将具有以下策略:

By default, WebKit will have the following policies:


  • 如果视频元素的源媒体不包含音频轨道,则无需用户手势即可自动播放。 b $ b
  • 视频静音元素也可以在没有用户手势的情况下自动播放。如果某个元素获得音轨或在没有用户手势的情况下取消静音,则播放将暂停。

  • video elements will be allowed to autoplay without a user gesture if their source media contains no audio tracks.
  • video muted elements will also be allowed to autoplay without a user gesture. If a element gains an audio track or becomes un-muted without a user gesture, playback will pause.

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

至于移动Chrome(Android): b
$ b

As for Mobile Chrome (Android):


Chrome for Android支持自动播放视频广告,截至
版本53.一旦自动播放和静音被设置为,一旦
进入视图,播放将自动启动视频元素,并且可以以原始方式启动
静音视频的播放与play()。以前,移动设备上的
播放必须由用户的手势启动,无论是静音状态的

Muted autoplay for video is supported by Chrome for Android as of version 53. Playback will start automatically for a video element once it comes into view if both autoplay and muted are set, and playback of muted videos can be initiated progamatically with play(). Previously, playback on mobile had to be initiated by a user gesture, regardless of the muted state.

https://developers.google.com/web/updates/2016/07/自动播放

这篇关于移动设备中的html5自动播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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