如何以编程方式检测特定的youtube用户实时流是否已启用 [英] How to programatically detect whether a particular youtube users Live streaming is enabled or not

查看:139
本文介绍了如何以编程方式检测特定的youtube用户实时流是否已启用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于创建和管理YouTube直播活动的应用程序. 一切都很好.我的应用程序中有最后一项要求,以检测用户是否确实为自己的帐户启用了直播功能. 根据结果​​,我的应用将继续进行事件创建/管理或直接退出.

I have an application to create and manage YouTube live events. It all works good. I've one last requirement in my app to detect whether the user has really enabled livestreaming for his account. Based on the result, my app will either proceed with event creation/management or simply exit.

注意:目前,这被检测为Google API异常

[未为用户启用实时流式传输. [403]].

[The user is not enabled for live streaming. [403]].

但是直到我们真正开始准备广播之前,这个异常才会发生. 我需要某种方式在我的逻辑中尽早发现它.

But this exception not hit till we actually start preparing the broadcast. I need some way to detect it somewhat early in my logic.

推荐答案

我知道有些晚了,但是我希望这种解决方案可以帮助现在遇到相同问题的人:

I know it is a bit late, but I hope this solution helps someone who faces the same problem now:

按照JAL的回答,我在开始流式传输之前创建了一个虚拟事件,如果它返回403状态代码或liveStreamingNotEnabled错误,我将停止广播并指导用户如何在其频道上启用实时流式传输.可以从( https://www.youtube.com/features 启用此功能,日航还提到,该页面没有具有糟糕UX的移动版本,因此用户无法通过此页面启用手机实时直播.

As per JAL's answer, I created a dummy event before I start streaming, if it returns a 403 status code or liveStreamingNotEnabled error, I'd stop the broadcast and guide the user as to how he can enable live streaming on his channel. This feature can be enabled from (https://www.youtube.com/features), but as JAL also mentioned, this page has no mobile version with terrible UX so the user can't enable live streaming from his phone through this page.

因此,为了克服此问题,我创建了一个Webview并加载了链接( https://www. youtube.com/live_streaming_signup ).这是按钮的操作,用于从功能页面启用实时流. Youtube从那里开始自动处理流程.之后,如果用户要再次创建事件,我将再次检查状态代码以确保启用了流式传输.如果没有,我将再次加载Web视图,依此类推.

So in order to overcome this problem, I created a webview and loaded the link (https://www.youtube.com/live_streaming_signup). This is the action of the button to enable live stream from the features page. Youtube handles the flow automatically from there on. After that, if the user wants to create an event again, I check the status code again to make sure streaming is enabled. If not, I load the webview again and so on.

这篇关于如何以编程方式检测特定的youtube用户实时流是否已启用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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