一个 YouTube 播放器,分别使用 2 个不同的 YouTube 视频作为音频和视频
我想知道是否可以使用 (JavaScript) YouTube API 动态创建一个使用两个不同 YouTube 视频作为其音频和视频源的播放器。换句话说,是否可以在 YouTube API 中隔离一个视频的音频和另一个视频的音频,然后在一个播放器中将它们一起流式传输?
I want to know if it is possible to use the (JavaScript) YouTube API to dynamically create a player that uses two different YouTube videos for its audio and video sources. In other words, is it possible within the YouTube API to isolate audio of one video and video of another and then stream them together within one player?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能可以通过加载并播放两个视频来伪造它,同时将纯音频视频保留在隐藏的 DIV 中,并使用 JS API 将纯视频视频静音。
所以我会尝试这样的事情:
诀窍是使用 CSS 设置 audiodiv 的样式,以便它不会出现在页面上。您可能需要尝试一下才能找到最佳组合,但我猜测将其宽度和高度设置为 0 或 1 应该就足够了。
此外,您可能需要设置 onYouTubePlayerReady 函数,以确保两个视频在开始播放之前已完全加载。
you could probably fake it by loading and playing both videos while keeping the audio-only video in a hidden DIV, and using the JS API to mute the video-only video.
So I would try something like this:
The trick then is to style audiodiv with CSS so that it doesn't appear on the page. You may need to play around with it to find the best combination, but I'm guessing that setting its width and height to 0 or 1 should be enough.
Also, you may need to set up the onYouTubePlayerReady function to make sure that both videos are completely loaded before you start playback.