From 41d55f22803ce8653336d0cbe8f6f8d7d0529944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20A=2E=20Matienzo?= Date: Tue, 2 Jul 2024 17:56:20 -0700 Subject: [PATCH] handle WebVTT captions in HLS manifests * add new helper methods to grab the URI for a WebVTT file included in a HLS manifest * insert new tags specifically for HLS streams * inject HLS.js configuration options to hide captions it renders this will require setting the property in all wowza collections to --- Gemfile | 1 + Gemfile.lock | 3 +++ app/views/player/_player_head_additional.erb | 3 +++ app/views/player/_video.html.erb | 4 +++- lib/av_player/track_extensions.rb | 22 ++++++++++++++++++++ spec/data/breslin1-playlist.m3u8 | 5 +++++ spec/data/subtitlelist_leng_w289808588.m3u8 | 7 +++++++ spec/lib/av_player/track_extensions_spec.rb | 19 +++++++++++++++++ 8 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 spec/data/breslin1-playlist.m3u8 create mode 100644 spec/data/subtitlelist_leng_w289808588.m3u8 diff --git a/Gemfile b/Gemfile index ec1b1af..e8a8a62 100644 --- a/Gemfile +++ b/Gemfile @@ -10,6 +10,7 @@ gem 'berkeley_library-docker', '~> 0.2.0' gem 'berkeley_library-logging', '~> 0.2' gem 'browser', '~> 4.2' gem 'jbuilder', '~> 2.7' +gem 'm3u8', '~> 0.8.2' gem 'non-stupid-digest-assets', '~> 1.0' # Allow static pages (e.g. 404.html) to link to compiled assets gem 'omniauth-cas', '~> 2.0' gem 'puma', '~> 5.3', '>= 5.3.1' diff --git a/Gemfile.lock b/Gemfile.lock index 436ae8e..7fce552 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -149,6 +149,7 @@ GEM loofah (2.21.4) crass (~> 1.0.2) nokogiri (>= 1.12.0) + m3u8 (0.8.2) mail (2.8.1) mini_mime (>= 0.1.1) net-imap @@ -352,6 +353,7 @@ PLATFORMS aarch64-linux arm64-darwin-21 arm64-darwin-22 + arm64-darwin-23 x86_64-darwin-19 x86_64-linux @@ -368,6 +370,7 @@ DEPENDENCIES dotenv-rails jbuilder (~> 2.7) listen (>= 3.0) + m3u8 (~> 0.8.2) non-stupid-digest-assets (~> 1.0) omniauth-cas (~> 2.0) puma (~> 5.3, >= 5.3.1) diff --git a/app/views/player/_player_head_additional.erb b/app/views/player/_player_head_additional.erb index 18983c6..0da0a9b 100644 --- a/app/views/player/_player_head_additional.erb +++ b/app/views/player/_player_head_additional.erb @@ -34,6 +34,9 @@ function initialize_players() { $("audio,video").mediaelementplayer({ + // workaround for mediaelement/mediaelement#2963 + // (when the HLS stream contains WebVTT captions) + hls: { enableWebVTT: false }, iconSprite: "/assets/icons/mejs-controls.svg", success: function (mediaElement, originalNode, instance) { if (typeof dashjs !== "undefined") { diff --git a/app/views/player/_video.html.erb b/app/views/player/_video.html.erb index faef104..4d40ed8 100644 --- a/app/views/player/_video.html.erb +++ b/app/views/player/_video.html.erb @@ -3,10 +3,12 @@