如何在Android的Youtube API V3中按频道ID获取Youtube实时流? [英] How to get Youtube Live Stream by Channel Id in Youtube API V3 in android?

查看:155
本文介绍了如何在Android的Youtube API V3中按频道ID获取Youtube实时流?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够获取实时流的列表: https ://developers.google.com/youtube/v3/live/docs/liveStreams/list#examples 但是,如何使用Android中的youtube v3 API获取特定频道的实时流状态和实时流链接或ID?

I am able to get the list of live stream: https://developers.google.com/youtube/v3/live/docs/liveStreams/list#examples But how to get the live stream status and live stream link or id for particular channel using youtube v3 api in android?

推荐答案

我遇到了同样的问题,并且设法找到了解决方案. YouTube实际上为此提供了一个API.如果您具有频道ID,则可以使用搜索API获取当前有效的实时视频ID.

I have faced the same problem and managed to figure out a solution for the same. YouTube actually provides an API for this purpose. You can use the search API to get the currently active Live Video ID, if you have the channel ID.

使用以下API:

https://www.googleapis.com/youtube/v3/search?part=snippet&channelId={YOUR_CHANNEL_ID}&eventType=live&type=video&key={YOUR_API_KEY}

这里的关键因素是必须将eventType设置为live,将type设置为video.

The key factor here is you have to set the eventType to live and type to video.

要获取频道ID,如果您具有频道的用户名,则可以使用以下请求.

For getting the channel ID, you can use the following request, if you have the channel's username.

https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername={CHANNEL_USER_NAME}&key={YOUR_API_KEY}

这篇关于如何在Android的Youtube API V3中按频道ID获取Youtube实时流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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