From 6bd0439471b69e1a1499a390b2842c17120550de Mon Sep 17 00:00:00 2001 From: Bilal Date: Tue, 25 Aug 2020 11:24:55 +0300 Subject: [PATCH 1/3] show recording preview thumbnail --- app/views/broadcasts/_broadcast_recordings.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/broadcasts/_broadcast_recordings.html.erb b/app/views/broadcasts/_broadcast_recordings.html.erb index 73f6f91..a49b36d 100644 --- a/app/views/broadcasts/_broadcast_recordings.html.erb +++ b/app/views/broadcasts/_broadcast_recordings.html.erb @@ -3,10 +3,11 @@ -- 2.47.3 From 7c828b4cd299f91e4d6d996fa5d630ff5e13e8a0 Mon Sep 17 00:00:00 2001 From: Bilal Date: Tue, 25 Aug 2020 11:33:49 +0300 Subject: [PATCH 2/3] add spec --- spec/features/user_managing_broadcasts_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/features/user_managing_broadcasts_spec.rb b/spec/features/user_managing_broadcasts_spec.rb index 9c40b71..3146d66 100644 --- a/spec/features/user_managing_broadcasts_spec.rb +++ b/spec/features/user_managing_broadcasts_spec.rb @@ -223,6 +223,18 @@ feature 'User managing broadcasts' do expect(page).to have_content("Recording of the live stream will appear here") end + scenario 'Broadcast recording preview thumbnail is shown' do + broadcast = create(:broadcast, :with_stream, :with_files, project: project) + recording = create(:broadcast_recording, broadcast: broadcast, asset_uid: "another_asset_uid") + + visit project_broadcast_path(project, broadcast) + + click_on 'Previous Sessions' + + expect(page).to have_css('img.img-thumbnail') + expect(page.find('img.img-thumbnail')['src']).to match recording.asset_playback_uid + end + context 'When the user is associate' do let(:current_user) { create(:user, :associate) } -- 2.47.3 From 41a9e83fb234a5a8250b06555ef887dca98a953a Mon Sep 17 00:00:00 2001 From: Bilal Date: Wed, 26 Aug 2020 14:08:40 +0300 Subject: [PATCH 3/3] fix MR comments --- app/models/broadcast_recording.rb | 4 ++++ app/views/broadcasts/_broadcast_recordings.html.erb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/broadcast_recording.rb b/app/models/broadcast_recording.rb index a7add7d..679df7e 100644 --- a/app/models/broadcast_recording.rb +++ b/app/models/broadcast_recording.rb @@ -18,4 +18,8 @@ class BroadcastRecording < ApplicationRecord def download_file_name "#{broadcast_name}_Date_#{created_at.in_time_zone(broadcast.shoot_location_time_zone).strftime("%Y-%m-%d")}_Time_#{created_at.in_time_zone(broadcast.shoot_location_time_zone).strftime("%T")}".parameterize end + + def thumbnail_url(width = 300) + "https://image.mux.com/#{asset_playback_uid}/thumbnail.jpg?width=#{width}" + end end diff --git a/app/views/broadcasts/_broadcast_recordings.html.erb b/app/views/broadcasts/_broadcast_recordings.html.erb index a49b36d..4041849 100644 --- a/app/views/broadcasts/_broadcast_recordings.html.erb +++ b/app/views/broadcasts/_broadcast_recordings.html.erb @@ -7,7 +7,7 @@ <% if (controller.class.module_parent.to_s != "Public" && policy(BroadcastRecording).destroy?) %> <%= link_to "Hide", [broadcast.project, broadcast, recording], class: "btn-sm btn-primary ml-1 text-decoration-none", remote: true, method: :delete, data: { confirm: t('.confirm_hide') } %> <% end %> - " alt="Recording preview"> + <%= image_tag(recording.thumbnail_url, class: 'img-thumbnail img-fluid mt-2 mb-2') %> <% end %> -- 2.47.3