How to get stream name/key of YouTube Live “Stream Now” service

[亡魂溺海] 提交于 2019-11-28 09:39:21

问题


YouTube added "Stream now (beta)" service last July which makes live streaming much easier.

Using Youtube verified programs like "XSplit Broadcaster" you can stream to "Stream now" after authorization.

I'm also doing a streaming application and what I'm looking for is the API to get the stream name of the default "Stream now" stream. With the stream name I can stream content to YouTube.

YouTube documentation https://developers.google.com/youtube/v3/live/docs/ doesn't mention anything about it, and the default broadcast is not included in the result of youtube.liveBroadcasts.list.

If XSplit Broadcaster can do it, I think there must have an API for it. Anyone knows it?

==================================== Update:

Form the documentation here https://developers.google.com/youtube/v3/live/docs/liveBroadcasts there should be a isDefault field in a Broadcast (snippet.isDefaultBroadcast). And there should be a default broadcast and default live stream.

But when I ran livebroadcasts.list to get all broadcasts, I got

{
 "kind": "youtube#liveBroadcastListResponse",
 "etag": "\"abQHWywil_AkNqdqji7_FqiK-u4/z2Ncj_KliOCAGV1jEVPYCsHbZn0\"",
 "pageInfo": {
  "totalResults": 4,
  "resultsPerPage": 50
 },
 "items": [
 ]
}

Although the totalResults = 4, there's nothing in returned items.


回答1:


Solved, the default broadcast can be retrieved by setting broadcastType to "persistent" in livebrocasts.list.

GET https://www.googleapis.com/youtube/v3/liveBroadcasts?part=+id%2C+snippet%2C+contentDetails%2C+status&broadcastType=persistent&mine=true&key={YOUR_API_KEY}

And default stream can be retrieved by livestreams.list with boundstreamid.



来源:https://stackoverflow.com/questions/35144186/how-to-get-stream-name-key-of-youtube-live-stream-now-service

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