Merge pull request #91 from omarroth/add-preferred-captions

Add preferred captions
This commit is contained in:
Omar Roth
2018-08-06 16:58:53 -05:00
committed by GitHub
6 changed files with 158 additions and 7 deletions

View File

@@ -55,7 +55,7 @@ video, #my_video, .video-js, .vjs-default-skin
<% end %>
<% captions.each do |caption| %>
<track kind="captions" src="/api/v1/captions/<%= video.id %>?label=<%= caption["name"]["simpleText"] %>"
srclang="<%= caption["languageCode"] %>" label="<%= caption["name"]["simpleText"]%> ">
label="<%= caption["name"]["simpleText"]%> ">
<% end %>
<% end %>
<% end %>

View File

@@ -56,6 +56,30 @@ function update_value(element) {
</select>
</div>
<div class="pure-control-group">
<label for="captions_0">Default captions: </label>
<select class="pure-u-1-5" name="captions_0" id="captions_0">
<% CAPTION_LANGUAGES.each do |option| %>
<option <% if user.preferences.captions[0] == option %> selected <% end %>><%= option %></option>
<% end %>
</select>
</div>
<div class="pure-control-group">
<label for="captions_fallback">Fallback languages: </label>
<select class="pure-u-1-5" name="captions_1" id="captions_1">
<% CAPTION_LANGUAGES.each do |option| %>
<option <% if user.preferences.captions[1] == option %> selected <% end %>><%= option %></option>
<% end %>
</select>
<select class="pure-u-1-5" name="captions_2" id="captions_2">
<% CAPTION_LANGUAGES.each do |option| %>
<option <% if user.preferences.captions[2] == option %> selected <% end %>><%= option %></option>
<% end %>
</select>
</div>
<legend>Visual preferences</legend>
<div class="pure-control-group">
<label for="dark_mode">Dark mode: </label>

View File

@@ -60,9 +60,14 @@
<% end %>
<% end %>
<% preferred_captions.each_with_index do |caption, i| %>
<track kind="captions" src="/api/v1/captions/<%= video.id %>?label=<%= caption["name"]["simpleText"] %>"
label="<%= caption["name"]["simpleText"]%>" <% if i == 0 %>default<% end %>>
<% end %>
<% captions.each do |caption| %>
<track kind="captions" src="/api/v1/captions/<%= video.id %>?label=<%= caption["name"]["simpleText"] %>"
srclang="<%= caption["languageCode"] %>" label="<%= caption["name"]["simpleText"]%> ">
label="<%= caption["name"]["simpleText"]%>">
<% end %>
<% end %>
<% end %>