diff --git a/app/controllers/master_files_controller.rb b/app/controllers/master_files_controller.rb index 98854b85c4..20bf66805c 100644 --- a/app/controllers/master_files_controller.rb +++ b/app/controllers/master_files_controller.rb @@ -325,6 +325,11 @@ def hls_manifest end end + def caption_manifest + return head :unauthorized if cannot?(:read, @master_file) + @caption = @master_file.captions + end + def structure authorize! :read, @master_file, message: "You do not have sufficient privileges" render json: @master_file.structuralMetadata.as_json diff --git a/app/views/master_files/caption_manifest.m3u8.erb b/app/views/master_files/caption_manifest.m3u8.erb new file mode 100644 index 0000000000..40fb3dfe54 --- /dev/null +++ b/app/views/master_files/caption_manifest.m3u8.erb @@ -0,0 +1,10 @@ +<% caption = captions_master_file_path %> + +#EXTM3U +#EXT-X-TARGETDURATION:<%= @master_file.duration %> +#EXT-X-VERSION:3 +#EXT-X-MEDIA-SEQUENCE:0 +#EXT-X-PLAYLIST-TYPE:VOD +#EXTINF:<%= @master_file.duration %> +<%= caption %> +#EXT-X-ENDLIST diff --git a/app/views/master_files/hls_manifest.m3u8.erb b/app/views/master_files/hls_manifest.m3u8.erb index e574584381..c2e12ea90a 100644 --- a/app/views/master_files/hls_manifest.m3u8.erb +++ b/app/views/master_files/hls_manifest.m3u8.erb @@ -14,7 +14,8 @@ Unless required by applicable law or agreed to in writing, software distributed --- END LICENSE_HEADER BLOCK --- %> #EXTM3U +#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",LANGUAGE="en",NAME="English",AUTOSELECT=YES,URI="<%= caption_manifest_master_file_path %>" <% @hls_streams.each do |hls| %> -#EXT-X-STREAM-INF:BANDWIDTH=<%= hls[:bitrate] %> +#EXT-X-STREAM-INF:BANDWIDTH=<%= hls[:bitrate] %>,SUBTITLES="subs" <%= hls[:url] %> <% end %> diff --git a/config/application.rb b/config/application.rb index 1d41ba160f..63e91c4dbc 100644 --- a/config/application.rb +++ b/config/application.rb @@ -47,6 +47,8 @@ class Application < Rails::Application resource '/master_files/*/structure.json', headers: :any, methods: [:get, :post, :delete] resource '/master_files/*/waveform.json', headers: :any, methods: [:get] resource '/master_files/*/*.m3u8', headers: :any, credentials: true, methods: [:get, :head] + resource '/master_files/*/caption_manifest', headers: :any, methods: [:get] + resource '/master_files/*/captions', headers: :any, methods: [:get] resource '/timelines/*/manifest.json', headers: :any, methods: [:get, :post] end end diff --git a/config/routes.rb b/config/routes.rb index 99a0b74db9..12e0482561 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -158,6 +158,7 @@ get :captions get :waveform match ':quality.m3u8', to: 'master_files#hls_manifest', via: [:get], as: :hls_manifest + get 'caption_manifest' get 'structure', to: 'master_files#structure', constraints: { format: 'json' } post 'structure', to: 'master_files#set_structure', constraints: { format: 'json' } delete 'structure', to: 'master_files#delete_structure', constraints: { format: 'json' }