mirror of
https://github.com/iv-org/invidious.git
synced 2024-09-11 12:02:25 +00:00
Add speed and fix <select> options
This commit is contained in:
parent
96c520b02b
commit
58b5e97fc4
@ -700,6 +700,9 @@ post "/preferences" do |env|
|
|||||||
autoplay ||= "off"
|
autoplay ||= "off"
|
||||||
autoplay = autoplay == "on"
|
autoplay = autoplay == "on"
|
||||||
|
|
||||||
|
speed = env.params.body["speed"]?.try &.as(String).to_f
|
||||||
|
speed ||= 1.0
|
||||||
|
|
||||||
quality = env.params.body["quality"]?.try &.as(String)
|
quality = env.params.body["quality"]?.try &.as(String)
|
||||||
quality ||= "hd720"
|
quality ||= "hd720"
|
||||||
|
|
||||||
@ -713,6 +716,7 @@ post "/preferences" do |env|
|
|||||||
preferences = {
|
preferences = {
|
||||||
"video_loop" => video_loop,
|
"video_loop" => video_loop,
|
||||||
"autoplay" => autoplay,
|
"autoplay" => autoplay,
|
||||||
|
"speed" => speed,
|
||||||
"quality" => quality,
|
"quality" => quality,
|
||||||
"volume" => volume,
|
"volume" => volume,
|
||||||
"dark_mode" => dark_mode,
|
"dark_mode" => dark_mode,
|
||||||
|
@ -20,6 +20,7 @@ end
|
|||||||
DEFAULT_USER_PREFERENCES = Preferences.from_json({
|
DEFAULT_USER_PREFERENCES = Preferences.from_json({
|
||||||
"video_loop" => false,
|
"video_loop" => false,
|
||||||
"autoplay" => false,
|
"autoplay" => false,
|
||||||
|
"speed" => 1.0,
|
||||||
"quality" => "hd720",
|
"quality" => "hd720",
|
||||||
"volume" => 100,
|
"volume" => 100,
|
||||||
"dark_mode" => false,
|
"dark_mode" => false,
|
||||||
@ -137,6 +138,7 @@ class Preferences
|
|||||||
JSON.mapping({
|
JSON.mapping({
|
||||||
video_loop: Bool,
|
video_loop: Bool,
|
||||||
autoplay: Bool,
|
autoplay: Bool,
|
||||||
|
speed: Float32,
|
||||||
quality: String,
|
quality: String,
|
||||||
volume: Int32,
|
volume: Int32,
|
||||||
dark_mode: Bool,
|
dark_mode: Bool,
|
||||||
|
@ -22,12 +22,21 @@ function update_value(element) {
|
|||||||
<input name="autoplay" id="autoplay" type="checkbox" <% if user.preferences.autoplay %>checked<% end %>>
|
<input name="autoplay" id="autoplay" type="checkbox" <% if user.preferences.autoplay %>checked<% end %>>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="pure-control-group">
|
||||||
|
<label for="speed">Default speed: </label>
|
||||||
|
<select name="speed" id="speed">
|
||||||
|
<% [2.0, 1.5, 1.0, 0.5].each do |option| %>
|
||||||
|
<option <% if user.preferences.speed == option %> selected <% end %>><%= option %></option>
|
||||||
|
<% end %>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="pure-control-group">
|
<div class="pure-control-group">
|
||||||
<label for="quality">Preferred video quality: </label>
|
<label for="quality">Preferred video quality: </label>
|
||||||
<select name="quality" id="quality" selected="<%= user.preferences.quality %>">
|
<select name="quality" id="quality">
|
||||||
<option>hd720</option>
|
<% ["hd720", "medium", "small"].each do |option| %>
|
||||||
<option>medium</option>
|
<option <% if user.preferences.quality == option %> selected <% end %>><%= option %></option>
|
||||||
<option>small</option>
|
<% end %>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -91,6 +91,7 @@ var player = videojs('player', options, function() {
|
|||||||
|
|
||||||
<% if preferences %>
|
<% if preferences %>
|
||||||
player.volume(<%= preferences.volume.to_f / 100 %>);
|
player.volume(<%= preferences.volume.to_f / 100 %>);
|
||||||
|
player.playbackRate(<%= preferences.speed %>);
|
||||||
<% end %>
|
<% end %>
|
||||||
player.offset({
|
player.offset({
|
||||||
start: <%= video_start %>,
|
start: <%= video_start %>,
|
||||||
|
Loading…
Reference in New Issue
Block a user