javascript - Videojs youtube视频没有在桌面Chrome的iframe中播放
问题描述
我正在从https://github.com/videojs/videojs-youtube在不同域的 iframe 中加载/videojs-youtube/examples/simple.html
示例页面。当我这样做时,视频不会播放,并且加载指示器会旋转并且不会停止。我在开发控制台中没有看到任何 javascript 错误。当我直接访问同一个文件时,视频播放没有任何问题。
该问题仅在最新的桌面 Chrome 72.0.3626.109 中出现。其他浏览器似乎没有。
这是我这边的屏幕截图:
https://www.youtube.com/watch?v=QBmre1vaLwI
现场示例:https ://jsfiddle.net/ws8tnc13/
iframe 来源:https ://alxd.ru/videojs-youtube/
页面源代码:
<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="./video.js/dist/video-js.min.css" />
</head>
<body>
<video
id="vid1"
class="video-js vjs-default-skin"
controls
autoplay
width="640" height="264"
data-setup='{ "techOrder": ["youtube", "html5"], "sources": [{ "type": "video/youtube", "src": "https://www.youtube.com/watch?v=xjS6SftYQaQ"}] }'
>
</video>
<script src="./video.js/dist/video.js"></script>
<script src="./Youtube.min.js"></script>
</body>
</html>
我会很感激任何帮助。
解决方案
用这个
<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/QBmre1vaLwI" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
推荐阅读
- swift - 使用泛型时 UIView 扩展的奇怪行为
- apache-spark - 运行 spark-submit 命令时无法将“spark”设置为服务帐户名称
- tensorflow - 在构建多标签图像分类模型时,二元交叉熵是唯一可以与 sigmoid 配对的损失函数吗?
- python-3.x - 修复第三方库中的内存泄漏
- python - 如何在单视图中在 Django 中拥有多个 ModelForm?
- bash - 是否有一个方便的等价物“find -mtime
" 一天中的部分时间 - linux - Wiki.js 无法通过企业代理
- primefaces - Primefaces 升级 8 getScriptsToExecute 等效
- quicksort - CS50 pset 3:Tideman sort_pairs 函数
- flutter - 播放 TTS 时降低背景音量