html - Youtube 视频以一帧加载

标签 html aframe

<!doctype html>
<html>
<head>
<title>multiple pseudo scenes</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/aframe/0.5.0/aframe.js">
</script>
</head>
<body>
<a-scene>
<a-assets>
<video id="video-src" autoplay="false" src="https://www.youtube.com/watch?
 v=Uz12cLvkVYY"></video>
</a-assets>
<a-video id="video-screen" src="#video-src"  position="1.591 2.206 -11" 
width="30" height="13">
</a-video>
</a-scene>
</body>
</html>

这是我的代码。我想使用帧在场景中加载 youtube 视频。但它没有显示任何内容。如何使用 a-frame 加载 YouTube 视频?

最佳答案

如果您可以将 youtube URL 放入 <video> 中,将会非常方便标签,但不幸的是,这不是它的工作原理。要在您的页面中嵌入 youtube 视频,您需要遵循 youtube 中的一种方法 API ,最终以一种或另一种方式在包含视频的页面中插入 iframe。

iframes can't be used inside a-frame :

There is no way for the browser to display <iframe>s within WebGL. While it is possible to overlay an <iframe> on top of the canvas, the <iframe> will not display in VR nor can it integrate with the scene.

进一步在 a-frame 文档中,youtube 是 specifically mentioned :

Can I render YouTube videos as a texture? No. You could proxy YouTube videos as a texture or download them locally to serve, but that is against their terms of service.

...这表明视频是可能的,但 youtube 不是(出于法律原因,而不是技术原因)。如果您需要这样做,您将需要一个非 YouTube 视频源。

关于html - Youtube 视频以一帧加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48623223/

相关文章:

html - 获取此 "simon says"游戏中间控件的标题和按钮

android - CSS:应用多个媒体查询

aframe - 我的 GLB 模型未加载 A-Frame 1.0.0

javascript - 在 AR 中制作动画

reactjs - Aframe 注销组件

javascript - 按钮点击动画

javascript - 使图像横幅自动旋转并单击

html - Bootstrap 布局问题 - 行 div 浮出容器

javascript - 平面中的文本不会在 A-Frame PWA 中离线显示

javascript - 可以在一个 Canvas 上制作具有多个 3D 模型的框架场景并与 JavaScript 链接吗?