Reputation: 192
I'm having trouble enabling 'RecordParticipantsOnConnect' as stated here: https://www.twilio.com/docs/video/api/recordings-resource in my twilio implementation but i can't seem to get it working, where do i set RecordParticipantsOnConnect to true?
They say you need to pass this option when you're creating a room, but i'm not creating any room, it's done automatically i'm just passing a room name as a string and i get the 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,
# 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
How do i solve this?
Upvotes: 2
Views: 1478
Reputation: 73029
Twilio developer evangelist here.
If you are letting the SDK dynamically creating the room when you join it then you won't be able to set the recording flag in your code. Instead, you have two choices:
You can configure your room default settings in the Twilio console. Here you can set the rooms to default to group rooms and to turn recording on. (You can't record peer-to-peer rooms because the media does not go through Twilio servers.)
You can create your room up front using the Video Rooms REST API. When creating a room yourself, you can also set the type and whether it is recorded. To do so, you'd update your get_token
method to something like:
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
Let me know if that helps at all.
Upvotes: 3