有没有办法在广播员直播时从 YouTube API 获取通知 [英] Is there a way to get notifications from YouTube API when broadcaster is live

查看:71
本文介绍了有没有办法在广播员直播时从 YouTube API 获取通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个应用程序,其中包含从 YouTube 流式传输计算机游戏的用户数据库,有没有办法从 YouTube API 获取通知,该通知会告诉我游戏玩家何时直播,以便我可以随机播放每个每个视频直播 2 分钟?

I'm creating a app that has a database of users who stream there computer game play from YouTube, is there a way to get a notification from YouTube API that will tell me when the gamer is live so I can randomly broadcast each live video for 2 minutes each?

推荐答案

我认为它需要在某些时候通过使用 ws://协议与您的 api 端点建立 websocket 连接.Websocket 侦听服务器,并使您的浏览器能够像事件一样处理它的变化.所以这正是您需要的通知.

I think it requires a websocket connection with your api endpoint by using ws:// protocole at some point. Websocket listen to a server, and enable your browser to handle it's changes like events. So it's exacly what u need for notifications.

在 RoR 5 中,您可以使用 ActionCable 来实现.

In RoR 5 you can do it using ActionCable.

我使用 Rails 5 的 ActionCable 来处理通知.但是我只用它来监听我自己的 Rails 应用程序的服务器内部的变化,而不是 API 端点,所以我无法为您提供分步指南.

I've used Rails 5's ActionCable to handle notifications. But sinds I've only used it to listening to changes inside the server of my own Rails app's and not an API endpoint so I won't be able to give you a step by step guide.

您应该查看如何与 API 端点建立动作电缆连接.

You should checkout how to make an action cable connection with an API end point.

这里的文档可能对您有所帮助:

Here is a documentaion that might help u out:

ActionCable 上的 RoR 文档

Websocket 上的 MDN 文档

这篇关于有没有办法在广播员直播时从 YouTube API 获取通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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