Youtube iFrame Api for live videos?

耗尽温柔 提交于 2021-01-27 14:26:47

问题


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.

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?


回答1:


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.

ex: 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', {});



来源:https://stackoverflow.com/questions/47241553/youtube-iframe-api-for-live-videos

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!