From 9ed7995829331e4c7ea66e4c762abcbc81b93e55 Mon Sep 17 00:00:00 2001 From: Mason Ballengee Date: Tue, 20 Feb 2024 10:38:30 -0500 Subject: [PATCH 1/3] Turn off feeding caption tracks into embedded player Captions are currently contained in the HLS manifest and these are parsed by VideoJS. We do not need to manually provide text tracks to the embedded player because of this. This commit also includes a change to the filtering of captions for the embedded player for if/when we reenable manually providing them so that issues will not arise for implementers who run the caption file migration. --- app/models/concerns/master_file_behavior.rb | 2 +- app/views/modules/player/_video_js_element.html.erb | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/models/concerns/master_file_behavior.rb b/app/models/concerns/master_file_behavior.rb index 6d0ca5dadb..9423a1bac5 100644 --- a/app/models/concerns/master_file_behavior.rb +++ b/app/models/concerns/master_file_behavior.rb @@ -60,7 +60,7 @@ def stream_details caption_paths = [] supplemental_file_captions.each { |c| caption_paths.append(build_caption_hash(c)) } - caption_paths.append(build_caption_hash(captions)) if captions + caption_paths.append(build_caption_hash(captions)) if captions.present? caption_paths end diff --git a/app/views/modules/player/_video_js_element.html.erb b/app/views/modules/player/_video_js_element.html.erb index d6db303126..70f7c1b18d 100644 --- a/app/views/modules/player/_video_js_element.html.erb +++ b/app/views/modules/player/_video_js_element.html.erb @@ -53,7 +53,7 @@ Unless required by applicable law or agreed to in writing, software distributed "userActions": { hotkeys: true } - }.compact.to_json %> + }.compact.to_json %>
<% end %> - <% if section_info[:caption_paths].present? %> + <%# Captions are contained in the HLS manifest and so we do not need to manually provide them to VideoJS here %> + <%# TODO: Reenable if/when we remove captions from HLS %> + <% skip_captions = true %> + <% if section_info[:caption_paths].present? && !skip_captions %> <% section_info[:caption_paths].each do |c| %> - label="<%= c[:label] %>" <% end %> srclang="<%= c[:language] %>" kind="subtitles" type="<%= c[:mime_type] %>" src="<%= c[:path] %>"> + label="<%= c[:label] %>" <% end %> srclang="<%= c[:language] %>" kind="subtitles" type="<%= c[:mime_type] %>" src="<%= c[:path] %>"> <% end %> <% end %> From cafdaea8fe351ca8364f165f995f08b2b13a8e73 Mon Sep 17 00:00:00 2001 From: Mason Ballengee Date: Tue, 20 Feb 2024 10:50:31 -0500 Subject: [PATCH 2/3] Fix indenting in erb file --- .../modules/player/_video_js_element.html.erb | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/views/modules/player/_video_js_element.html.erb b/app/views/modules/player/_video_js_element.html.erb index 70f7c1b18d..24c8afe746 100644 --- a/app/views/modules/player/_video_js_element.html.erb +++ b/app/views/modules/player/_video_js_element.html.erb @@ -43,16 +43,16 @@ Unless required by applicable law or agreed to in writing, software distributed end %> <% @videojs_options = { - "autoplay": false, - "width": @player_width || 480, - "height": @player_height || 270, - "bigPlayButton": section_info[:is_video] ? true : false, - "poster": section_info[:is_video] ? section_info[:poster_image] : false, - "preload": "auto", - "controlBar": control_bar_options, - "userActions": { - hotkeys: true - } + "autoplay": false, + "width": @player_width || 480, + "height": @player_height || 270, + "bigPlayButton": section_info[:is_video] ? true : false, + "poster": section_info[:is_video] ? section_info[:poster_image] : false, + "preload": "auto", + "controlBar": control_bar_options, + "userActions": { + hotkeys: true + } }.compact.to_json %>
@@ -69,7 +69,7 @@ Unless required by applicable law or agreed to in writing, software distributed <% skip_captions = true %> <% if section_info[:caption_paths].present? && !skip_captions %> <% section_info[:caption_paths].each do |c| %> - label="<%= c[:label] %>" <% end %> srclang="<%= c[:language] %>" kind="subtitles" type="<%= c[:mime_type] %>" src="<%= c[:path] %>"> + label="<%= c[:label] %>" <% end %> srclang="<%= c[:language] %>" kind="subtitles" type="<%= c[:mime_type] %>" src="<%= c[:path] %>"> <% end %> <% end %> From f0f1df937c44984a801f51ba49a97be3fdfcb31e Mon Sep 17 00:00:00 2001 From: dwithana Date: Tue, 20 Feb 2024 10:37:18 -0500 Subject: [PATCH 3/3] Enable create timeline and create thumbnail buttons on timeout --- app/views/media_objects/_thumbnail.html.erb | 11 +++++++++++ app/views/media_objects/_timeline.html.erb | 13 ++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/views/media_objects/_thumbnail.html.erb b/app/views/media_objects/_thumbnail.html.erb index 4512344d44..2310c1a2b7 100644 --- a/app/views/media_objects/_thumbnail.html.erb +++ b/app/views/media_objects/_thumbnail.html.erb @@ -61,6 +61,17 @@ Unless required by applicable law or agreed to in writing, software distributed } clearInterval(timeCheck); }); + /* + Browsers on MacOS sometimes miss the 'loadedmetadata' event resulting in a disabled add to playlist button indefinitely. + This timeout enables the add to playlist button, when this happens. It checks the button's state and enables it as needed. + */ + setTimeout(() => { + let thumbnailBtn = document.getElementById('create-thumbnail-btn'); + if (thumbnailBtn && thumbnailBtn.disabled) { + thumbnailBtn.disabled = false; + } + clearInterval(timeCheck); + }, 500); } $('#thumbnailModal').on('show.bs.modal', function(e) { diff --git a/app/views/media_objects/_timeline.html.erb b/app/views/media_objects/_timeline.html.erb index 1d546e0a32..f5f3f22f27 100644 --- a/app/views/media_objects/_timeline.html.erb +++ b/app/views/media_objects/_timeline.html.erb @@ -51,11 +51,22 @@ $(document).ready(function() { if(player && player != undefined) { player.player.on('loadedmetadata', () => { let timelineBtn = document.getElementById('timelineBtn'); - if(timelineBtn) { + if (timelineBtn) { timelineBtn.disabled = false; } clearInterval(timeCheck); }); + /* + Browsers on MacOS sometimes miss the 'loadedmetadata' event resulting in a disabled add to playlist button indefinitely. + This timeout enables the add to playlist button, when this happens. It checks the button's state and enables it as needed. + */ + setTimeout(() => { + let timelineBtn = document.getElementById('timelineBtn'); + if (timelineBtn && timelineBtn.disabled) { + timelineBtn.disabled = false; + } + clearInterval(timeCheck); + }, 500); } $('#timelineModal').on('shown.bs.modal', function (e) {