HTML5视频仅在移动设备上播放(droid chrome mobile) [英] HTML5 video only playing onclick on mobile device (droid chrome mobile)

查看:91
本文介绍了HTML5视频仅在移动设备上播放(droid chrome mobile)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们来看看代码:

我正在准备文件:
< video width =300 height =400id =videoStage>< / video>< button onclick ='video()'>播放视频< / button>

与JS函数一样:

  function video(){
    var vid_url = "https://fbcdn-video-a.akamaihd.net/cfs-ak-ash4/v/82342/969/274169121921_63622.mp4?oh=99ef0d9285cbbd7adf8bc07a845dc0d1&oe=519E400F&__gda__=1369439362_83c7f900e92bdbaa201f49d35a7c144a";
    stage = document.getElementById('videoStage');
    stage.src = vid_url;
    stage.play();
  }

工作代码示例: http://jsbin.com/eviyel/1

此代码工作正常并播放视频在我的桌面和我的移动设备上。
但是(!)当video()函数应用于document.ready时 - 它只在我的桌面上播放,而对于我的移动设备,它显示为空。

this code works just fine and plays the video both on my desktop and my mobile device. But(!) when the video() function is applied to document.ready - it only plays on my desktop and as for my mobile device it displays empty.

任何解决方案的家伙? 10x。

Any solution guys? 10x.

推荐答案

从iOS 10开始自动播放允许静音的视频,无需用户互动:

Starting from iOS 10 autoplaying videos that are muted is allowed without user interaction:

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

Android似乎仍然需要用户互动,尽管可能会使用touchend滚动页面以开始视频播放的事件。

Android still seems to require user interaction, although it might be possible to use a touchend event from scrolling the page to start the video playback.

这篇关于HTML5视频仅在移动设备上播放(droid chrome mobile)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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