在移动浏览器上自动播放视频元素

在移动浏览器上自动播放视频元素

本文介绍了在移动浏览器上自动播放视频元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了自动播放是不可能的,或者在iOS和Android上都没有建议(更多在这里:)上的-html5-player-on-mobile-android-chrome-and-firefox。但是我想知道是否有一种方式可以复制相同的行为,那就是视频在页面加载时播放。



我已经尝试预加载视频,并且一旦DOM被加载,我尝试强迫播放,因为视频可以播放,没有一个工作,它总是导致用户不得不点击视频播放。



任何人都可以帮助?



注意:我正在使用纯旧的JavaScript,没有jQuery。

解决方案

不,iOS / Safari(或iBooks)没有办法。
视频只在事件处理程序的上下文中加载,以响应用户操作(如触摸)。
你没有运气。



这在SO上的任何数量的问题都已经被广泛记录下来了,并且被Apple清楚地记录了。 p>

I have read that autoplay was not possible, or not advised on both iOS and Android (more on that here: no autoplay in iframe HTML5 player on mobile (Android Chrome and Firefox)?). But I was wondering if there was a way that would allow to replicate the same behavior, that is the video playing soon as the page is loaded.

I have tried preloading the video, and playing it once the DOM is loaded, I tried forcing a play soon as the video can be played, none of that work, it always result in the user having to tap the video to play it.

Can anyone help?

NB: I'm working with plain old JavaScript, no jQuery.

解决方案

No, there is no way on iOS/Safari (or iBooks).Videos load only in the context of an event handler reacting to user action such as a touch.You're out of luck.

This has been documented extensively in any number of questions right here on SO, and is clearly documented by Apple.

这篇关于在移动浏览器上自动播放视频元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 22:59