我正在为客户开发一个网站,但我被困在这一点上,因为我们都能够在 Android 上的 Chrome 中重新创建这个问题。
无论出于何种原因,当我们在 Chrome 中的 Android 上加载此页面时:
http://miso.gostppro.com
视频加载器只是不停地旋转,视频永远不会播放。
并且点击它也不会做任何事情(不会开始播放,不会在 YouTube 应用程序中打开它,什么都没有)。
它在其他浏览器中运行良好(Firefox for Android 加载并播放它很好),所以我对为什么会发生这种情况感到困惑。
我错过了什么?
是API中的一些调用还是什么?
我迷路了。
最佳答案
简而言之,它不会起作用。引用 documentation :
The HTML5 element, in certain mobile browsers (such as Chrome and Safari), only allows playback to take place if it's initiated by a user interaction (such as tapping on the player). (...) Due to this restriction, functions and parameters such as autoplay, playVideo(), loadVideoById() won't work in all mobile environments.
您调用
event.target.playVideo();
在您的 onPlayerReady
处理程序,这在移动环境中是不允许的,并且会在控制台中引发警告(以供将来引用 - 我强烈建议在 Chrome 中使用 Remote Debugging)。所以,回到你的问题 - 我只是摆脱
onPlayerReady
处理程序和使用 autoplay
而是播放器变量。它应该可以在台式机上运行,也不会破坏移动设备上的播放器。
关于youtube-api - YouTube 视频(使用最新 API)无法在 Android 上的 Chrome 上播放?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36799918/