add live meeting in broadcast screen
This commit is contained in:
@@ -32,3 +32,6 @@ CUSTOM_API_TOKEN=
|
|||||||
# Required for simulcasting to Millicast for director mode
|
# Required for simulcasting to Millicast for director mode
|
||||||
MILLICAST_API_SECRET=
|
MILLICAST_API_SECRET=
|
||||||
MILLICAST_ACCOUNT_ID=
|
MILLICAST_ACCOUNT_ID=
|
||||||
|
|
||||||
|
# Daily.co live chat API token
|
||||||
|
DAILY_API_TOKEN=
|
||||||
@@ -114,7 +114,7 @@ class BroadcastsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def conference_url_for(broadcast)
|
def conference_url_for(broadcast)
|
||||||
broadcast.video_conference_url_override.presence || url_for([broadcast.project, broadcast, :zoom_meeting])
|
broadcast.video_conference_url_override.presence || url_for([broadcast.project, broadcast, :live_meeting])
|
||||||
end
|
end
|
||||||
|
|
||||||
def log_create_analytics
|
def log_create_analytics
|
||||||
|
|||||||
6
app/controllers/live_meetings_controller.rb
Normal file
6
app/controllers/live_meetings_controller.rb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
class LiveMeetingsController < ApplicationController
|
||||||
|
def show
|
||||||
|
authorize broadcast = Broadcast.find(params[:broadcast_id])
|
||||||
|
@live_meeting_url = broadcast.project.live_meeting_url
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -44,7 +44,7 @@ class Public::BroadcastsController < Public::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def conference_url_for(broadcast)
|
def conference_url_for(broadcast)
|
||||||
broadcast.video_conference_url_override.presence || broadcast_zoom_meeting_url(broadcast.token)
|
broadcast.video_conference_url_override.presence || broadcast_live_meeting_url(broadcast.token)
|
||||||
end
|
end
|
||||||
|
|
||||||
class MultiViewBroadcast
|
class MultiViewBroadcast
|
||||||
|
|||||||
9
app/controllers/public/live_meetings_controller.rb
Normal file
9
app/controllers/public/live_meetings_controller.rb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
class Public::LiveMeetingsController < Public::BaseController
|
||||||
|
skip_after_action :verify_authorized
|
||||||
|
|
||||||
|
def show
|
||||||
|
broadcast = Broadcast.find_by_token!(params[:broadcast_token])
|
||||||
|
@live_meeting_url = broadcast.project.live_meeting_url
|
||||||
|
render 'public/live_meetings/show'
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -14,6 +14,7 @@ class Broadcast < ApplicationRecord
|
|||||||
|
|
||||||
# Should we use callbacks for this, or something else?
|
# Should we use callbacks for this, or something else?
|
||||||
after_create :create_mux_live_stream
|
after_create :create_mux_live_stream
|
||||||
|
after_create :create_live_meeting_if_not_created
|
||||||
after_destroy :destroy_mux_live_stream
|
after_destroy :destroy_mux_live_stream
|
||||||
|
|
||||||
pg_search_scope :search, {
|
pg_search_scope :search, {
|
||||||
@@ -59,6 +60,14 @@ class Broadcast < ApplicationRecord
|
|||||||
self.save!
|
self.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_live_meeting_if_not_created
|
||||||
|
if project.live_meeting_url.blank?
|
||||||
|
room = Daily.create_room
|
||||||
|
room_url = room['url']
|
||||||
|
project.update live_meeting_url: room_url
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def destroy_mux_live_stream
|
def destroy_mux_live_stream
|
||||||
begin
|
begin
|
||||||
stream = MuxLiveStream.new
|
stream = MuxLiveStream.new
|
||||||
|
|||||||
13
app/views/live_meetings/show.html.erb
Normal file
13
app/views/live_meetings/show.html.erb
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<%= javascript_include_tag "https://unpkg.com/@daily-co/daily-js" %>
|
||||||
|
|
||||||
|
<%= javascript_tag nonce: true do %>
|
||||||
|
callFrame = window.DailyIframe.createFrame({
|
||||||
|
showLeaveButton: true,
|
||||||
|
iframeStyle: {
|
||||||
|
position: 'fixed',
|
||||||
|
width: '100%',
|
||||||
|
height: '90%'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
callFrame.join({ url: '<%= @live_meeting_url %>' });
|
||||||
|
<% end %>
|
||||||
13
app/views/public/live_meetings/show.html.erb
Normal file
13
app/views/public/live_meetings/show.html.erb
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<%= javascript_include_tag "https://unpkg.com/@daily-co/daily-js" %>
|
||||||
|
|
||||||
|
<%= javascript_tag nonce: true do %>
|
||||||
|
callFrame = window.DailyIframe.createFrame({
|
||||||
|
showLeaveButton: true,
|
||||||
|
iframeStyle: {
|
||||||
|
position: 'fixed',
|
||||||
|
width: '100%',
|
||||||
|
height: '90%'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
callFrame.join({ url: '<%= @live_meeting_url %>' });
|
||||||
|
<% end %>
|
||||||
1
config/initializers/daily.rb
Normal file
1
config/initializers/daily.rb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
require 'daily'
|
||||||
@@ -104,7 +104,7 @@ Rails.application.routes.draw do
|
|||||||
member do
|
member do
|
||||||
delete :destroy_file
|
delete :destroy_file
|
||||||
end
|
end
|
||||||
resource :zoom_meeting, only: [:show]
|
resource :live_meeting, only: [:show]
|
||||||
resources :broadcast_recordings, only: [:destroy]
|
resources :broadcast_recordings, only: [:destroy]
|
||||||
end
|
end
|
||||||
resources :directories, except: [:index] do
|
resources :directories, except: [:index] do
|
||||||
@@ -149,7 +149,7 @@ Rails.application.routes.draw do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :broadcasts, param: :token, only: [:show, :update] do
|
resources :broadcasts, param: :token, only: [:show, :update] do
|
||||||
resource :zoom_meeting, only: [:show]
|
resource :live_meeting, only: [:show]
|
||||||
resources :broadcast_recordings, only: [:edit, :update] do
|
resources :broadcast_recordings, only: [:edit, :update] do
|
||||||
resources :broadcast_recording_starrings, only: :create
|
resources :broadcast_recording_starrings, only: :create
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class AddLiveMeetingUrlToProjects < ActiveRecord::Migration[6.0]
|
||||||
|
def change
|
||||||
|
add_column :projects, :live_meeting_url, :text
|
||||||
|
end
|
||||||
|
end
|
||||||
26
lib/daily.rb
Normal file
26
lib/daily.rb
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Daily
|
||||||
|
include HTTParty
|
||||||
|
base_uri 'api.daily.co/v1'
|
||||||
|
|
||||||
|
class << self
|
||||||
|
def create_room
|
||||||
|
response = post "#{base_uri}/rooms", headers: headers
|
||||||
|
|
||||||
|
if response.code != 200
|
||||||
|
throw StandardError.new('Failed to create a room')
|
||||||
|
end
|
||||||
|
|
||||||
|
response.parsed_response
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def headers
|
||||||
|
{
|
||||||
|
'Authorization': "Bearer #{ENV['DAILY_API_TOKEN']}"
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user