iPhone 6s 上的一个 Three.js 视频示例不起作用(只有黑色面板) [英] one three.js example of video on iPhone 6s did not work( only black panel)

查看:59
本文介绍了iPhone 6s 上的一个 Three.js 视频示例不起作用(只有黑色面板)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iPhone 6s 上的一个 Three.js 视频示例不起作用(只有黑色面板)

one three.js example of video on iPhone 6s did not work( only black panel)

https://stemkoski.github.io/Three.js/Video.html

但该示例在 PC 桌面浏览器上运行良好.它在 Safari & 中失败了iPhone 6s 上的 Chronme

But the example works fine on PC desktop browser. It failed in Safari & Chronme on iPhone 6s

推荐答案

截至 2019 年 iOS 的解决方案是

As of 2019 the solution for iOS is

  1. 您必须在点击"或触摸启动"等用户手势事件中启动视频

  1. you have to start the video in user gesture event like 'click' or 'touchstart'

否则浏览器将拒绝播放视频

Otherwise the browser will refuse to play the video

someElement.addEventListener('click', () => {
 videoElement.play();
});

  • 你必须将 playsInline 设置为 true

    videoElement.playsInline = true;
    

  • 这是一个从 iOS 12 开始的工作示例

    Here's a working example as of iOS 12

    http://webglsamples.org/video/video.html

    这篇关于iPhone 6s 上的一个 Three.js 视频示例不起作用(只有黑色面板)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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