YouTube的iFrame Api直播视频? [英] Youtube iFrame Api for live videos?

查看:83
本文介绍了YouTube的iFrame Api直播视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用youtube iframe api实现来自youtube频道的实时视频.api中有一个videoId属性,它也适用于实时视频,但是我们必须在每个流开始时添加视频ID.

I'm trying to implement live video from youtube channel with youtube iframe api. There is a videoId property in api and it works for live videos too but we have to add video id every stream start.

iframe实时视频 https://www.youtube.com/embed/live_stream?channel=CHANNEL_ID 中有一个解决方案.如何在iframe API中使用它?

There is a solution in iframe live video https://www.youtube.com/embed/live_stream?channel=CHANNEL_ID. How can i use it in iframe api?

推荐答案

我遇到了同样的问题.我发现您可以直接使用src而不是空div添加iframe.然后给它一个id并将其传递给新的YT.Player实例.

I came across this same issue. I figured out that you can directly add the iframe with the src instead of an empty div. Then give it an id and pass that to the new YT.Player instance.

例如:的HTML:< iframe id ="player" src ="https://www.youtube.com/embed/live_stream?channel=CHANNEL_ID?enablejsapi=1"></iframe>

js: var player = new YT.Player('player',{});

这篇关于YouTube的iFrame Api直播视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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