ruby-on-rails - 如何在 Twilio 视频会议中启用录制?
问题描述
我在启用“RecordParticipantsOnConnect”时遇到问题,如此处所述:https : //www.twilio.com/docs/video/api/recordings-resource 在我的 twilio 实现中,但我似乎无法让它工作,我在哪里将 RecordParticipantsOnConnect 设置为 true?
他们说你在创建房间时需要传递这个选项,但我没有创建任何房间,它是自动完成的,我只是将房间名称作为字符串传递,我得到了令牌:
class TwilioServices
ACCOUNT_SID = ENV['TWILIO_ACCOUNT_SID']
API_KEY_SID = ENV['TWILIO_API_KEY_SID']
API_KEY_SECRET = ENV['TWILIO_API_KEY_SECRET']
def self.get_token(type, room)
# Create an Access Token
token = Twilio::JWT::AccessToken.new ACCOUNT_SID, API_KEY_SID, API_KEY_SECRET, ttl: 7200, identity: type,
# Grant access to Video
grant = Twilio::JWT::AccessToken::VideoGrant.new
grant.room = room
token.add_grant grant
# Serialize the token as a JWT
token.to_jwt
end
end
我该如何解决这个问题?
解决方案
Twilio 开发人员布道者在这里。
如果您在加入时让 SDK 动态创建房间,那么您将无法在代码中设置录制标志。相反,您有两种选择:
您可以在 Twilio 控制台中配置您的房间默认设置。在这里,您可以将房间设置为默认分组房间并打开录制。(您无法录制点对点房间,因为媒体不通过 Twilio 服务器。)
您可以使用Video Rooms REST API 预先创建您的房间。自己创建房间时,还可以设置类型和是否录制。为此,您需要将
get_token
方法更新为:class TwilioServices ACCOUNT_SID = ENV['TWILIO_ACCOUNT_SID'] API_KEY_SID = ENV['TWILIO_API_KEY_SID'] API_KEY_SECRET = ENV['TWILIO_API_KEY_SECRET'] def self.get_token(type, room) # Create an Access Token token = Twilio::JWT::AccessToken.new ACCOUNT_SID, API_KEY_SID, API_KEY_SECRET, ttl: 7200, identity: type, client = Twilio::REST::Client.new(API_KEY_SID, API_KEY_SECRET, ACCOUNT_SID) video_room = client.video.rooms.create( unique_name: room, record_participants_on_connect: true, type: 'group' ) # Grant access to Video grant = Twilio::JWT::AccessToken::VideoGrant.new grant.room = room token.add_grant grant # Serialize the token as a JWT token.to_jwt end end
让我知道这是否有帮助。
推荐阅读
- ios - iOS 12.1.1 beta 中的电子邮件配置安装流程
- css - 在撇号-cms 中的另一个 DIV 小部件中动态添加 DIV 小部件
- php - 未来的时间戳格式为 1. January 1970 with PHP date()
- java - WAR 文件 servlet 访问:ClassNotFoundException
- git - 在 git 中,在将生产中的两个分支合并到本地分支后,如何从服务器获取文件?
- sql-server - 在链接服务器上运行动态查询
- php - php msqli 将记录从一个数据库移动到另一个数据库
- java - 金额值比较规则产生不一致的结果 - Drools
- python - creating a pandas dataframe based on cell content of two other dataframes
- python - GridSearchCV 返回不同的值