diff --git a/app/assets/javascripts/channels/broadcasts.coffee b/app/assets/javascripts/channels/broadcasts.coffee index 9ed744f..f163bee 100644 --- a/app/assets/javascripts/channels/broadcasts.coffee +++ b/app/assets/javascripts/channels/broadcasts.coffee @@ -21,7 +21,8 @@ $(document).on "turbolinks:load", -> refreshBroadcastVideo: (data) -> $("#broadcast_updates").html data.status_content - if data.streamer_status == 'recording' && data.status == 'active' + stream_selected = $("#broadcast_video").attr('video-type') == 'stream'; + if data.streamer_status == 'recording' && data.status == 'active' && stream_selected $("#broadcast_video").html data.video_content new (Clappr.Player)( parentId: '#broadcast_video' diff --git a/app/assets/javascripts/play_previous_recordings.js.erb b/app/assets/javascripts/stream_player.js.erb similarity index 80% rename from app/assets/javascripts/play_previous_recordings.js.erb rename to app/assets/javascripts/stream_player.js.erb index c3c7b49..4a9f00d 100644 --- a/app/assets/javascripts/play_previous_recordings.js.erb +++ b/app/assets/javascripts/stream_player.js.erb @@ -3,7 +3,7 @@ $(document).on("click", "[data-behavior=play_recording]", function() { return false; } - console.warn('Play prev : ', playback_url); + $("#broadcast_video").attr('video-type', 'recording'); var playback_url = $(this).attr("data-playback-url") $("#broadcast_video").empty(); @@ -23,4 +23,6 @@ $(document).on("click", "[data-behavior=play_recording]", function() { $(this).siblings().children("i").remove(); $(this).addClass('active'); $(this).prepend(' '); -}); \ No newline at end of file +}); + +$(document).on("click", "[data-behavior=play_stream]", function() { $("#broadcast_video").attr('video-type', 'stream'); }); \ No newline at end of file diff --git a/app/views/broadcasts/show.html.erb b/app/views/broadcasts/show.html.erb index 12e0a93..d36fccc 100644 --- a/app/views/broadcasts/show.html.erb +++ b/app/views/broadcasts/show.html.erb @@ -33,10 +33,10 @@ <%= link_to "Switch View", "#", class: "btn btn-light border dropdown-toggle", role: "button", id: "dropdownMenuLink", data: { toggle: "dropdown" }, aria: { haspopup: "true", expanded: "false" } %>