mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-26 07:49:23 -05:00
Add DASH quality preference
The options are `auto` (the current and default behavior), `best` and `worst`. The UI is only updated once playback starts.
This commit is contained in:
parent
c7c732ebc0
commit
eea7ca9b72
@ -154,6 +154,18 @@ if (video_data.params.autoplay) {
|
|||||||
|
|
||||||
if (!video_data.params.listen && video_data.params.quality === 'dash') {
|
if (!video_data.params.listen && video_data.params.quality === 'dash') {
|
||||||
player.httpSourceSelector();
|
player.httpSourceSelector();
|
||||||
|
|
||||||
|
if (video_data.params.quality_dash != "auto") {
|
||||||
|
player.ready(() => {
|
||||||
|
player.on("loadedmetadata", () => {
|
||||||
|
const qualityLevels = Array.from(player.qualityLevels()).sort((a, b) => a.height - b.height);
|
||||||
|
const targetQualityLevel = video_data.params.quality_dash == "best" ? qualityLevels.length - 1 : 0;
|
||||||
|
for (let i = 0; i < qualityLevels.length; i++) {
|
||||||
|
qualityLevels[i].enabled = (i == targetQualityLevel)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
player.vttThumbnails({
|
player.vttThumbnails({
|
||||||
@ -510,4 +522,6 @@ window.addEventListener('keydown', e => {
|
|||||||
}());
|
}());
|
||||||
|
|
||||||
// Since videojs-share can sometimes be blocked, we defer it until last
|
// Since videojs-share can sometimes be blocked, we defer it until last
|
||||||
player.share(shareOptions);
|
if (player.share) {
|
||||||
|
player.share(shareOptions);
|
||||||
|
}
|
||||||
|
@ -41,6 +41,7 @@ struct ConfigPreferences
|
|||||||
property notifications_only : Bool = false
|
property notifications_only : Bool = false
|
||||||
property player_style : String = "invidious"
|
property player_style : String = "invidious"
|
||||||
property quality : String = "hd720"
|
property quality : String = "hd720"
|
||||||
|
property quality_dash : String = "auto"
|
||||||
property default_home : String = "Popular"
|
property default_home : String = "Popular"
|
||||||
property feed_menu : Array(String) = ["Popular", "Trending", "Subscriptions", "Playlists"]
|
property feed_menu : Array(String) = ["Popular", "Trending", "Subscriptions", "Playlists"]
|
||||||
property related_videos : Bool = true
|
property related_videos : Bool = true
|
||||||
|
@ -54,6 +54,9 @@ class Invidious::Routes::UserPreferences < Invidious::Routes::BaseRoute
|
|||||||
quality = env.params.body["quality"]?.try &.as(String)
|
quality = env.params.body["quality"]?.try &.as(String)
|
||||||
quality ||= CONFIG.default_user_preferences.quality
|
quality ||= CONFIG.default_user_preferences.quality
|
||||||
|
|
||||||
|
quality_dash = env.params.body["quality_dash"]?.try &.as(String)
|
||||||
|
quality_dash ||= CONFIG.default_user_preferences.quality_dash
|
||||||
|
|
||||||
volume = env.params.body["volume"]?.try &.as(String).to_i?
|
volume = env.params.body["volume"]?.try &.as(String).to_i?
|
||||||
volume ||= CONFIG.default_user_preferences.volume
|
volume ||= CONFIG.default_user_preferences.volume
|
||||||
|
|
||||||
@ -127,6 +130,7 @@ class Invidious::Routes::UserPreferences < Invidious::Routes::BaseRoute
|
|||||||
notifications_only: notifications_only,
|
notifications_only: notifications_only,
|
||||||
player_style: player_style,
|
player_style: player_style,
|
||||||
quality: quality,
|
quality: quality,
|
||||||
|
quality_dash: quality_dash,
|
||||||
default_home: default_home,
|
default_home: default_home,
|
||||||
feed_menu: feed_menu,
|
feed_menu: feed_menu,
|
||||||
related_videos: related_videos,
|
related_videos: related_videos,
|
||||||
|
@ -66,6 +66,8 @@ struct Preferences
|
|||||||
|
|
||||||
@[JSON::Field(converter: Preferences::ProcessString)]
|
@[JSON::Field(converter: Preferences::ProcessString)]
|
||||||
property quality : String = CONFIG.default_user_preferences.quality
|
property quality : String = CONFIG.default_user_preferences.quality
|
||||||
|
@[JSON::Field(converter: Preferences::ProcessString)]
|
||||||
|
property quality_dash : String = CONFIG.default_user_preferences.quality_dash
|
||||||
property default_home : String = CONFIG.default_user_preferences.default_home
|
property default_home : String = CONFIG.default_user_preferences.default_home
|
||||||
property feed_menu : Array(String) = CONFIG.default_user_preferences.feed_menu
|
property feed_menu : Array(String) = CONFIG.default_user_preferences.feed_menu
|
||||||
property related_videos : Bool = CONFIG.default_user_preferences.related_videos
|
property related_videos : Bool = CONFIG.default_user_preferences.related_videos
|
||||||
|
@ -235,6 +235,7 @@ struct VideoPreferences
|
|||||||
property preferred_captions : Array(String)
|
property preferred_captions : Array(String)
|
||||||
property player_style : String
|
property player_style : String
|
||||||
property quality : String
|
property quality : String
|
||||||
|
property quality_dash : String
|
||||||
property raw : Bool
|
property raw : Bool
|
||||||
property region : String?
|
property region : String?
|
||||||
property related_videos : Bool
|
property related_videos : Bool
|
||||||
@ -1043,6 +1044,7 @@ def process_video_params(query, preferences)
|
|||||||
player_style = query["player_style"]?
|
player_style = query["player_style"]?
|
||||||
preferred_captions = query["subtitles"]?.try &.split(",").map { |a| a.downcase }
|
preferred_captions = query["subtitles"]?.try &.split(",").map { |a| a.downcase }
|
||||||
quality = query["quality"]?
|
quality = query["quality"]?
|
||||||
|
quality_dash = query["quality_dash"]?
|
||||||
region = query["region"]?
|
region = query["region"]?
|
||||||
related_videos = query["related_videos"]?.try { |q| (q == "true" || q == "1").to_unsafe }
|
related_videos = query["related_videos"]?.try { |q| (q == "true" || q == "1").to_unsafe }
|
||||||
speed = query["speed"]?.try &.rchop("x").to_f?
|
speed = query["speed"]?.try &.rchop("x").to_f?
|
||||||
@ -1061,6 +1063,7 @@ def process_video_params(query, preferences)
|
|||||||
player_style ||= preferences.player_style
|
player_style ||= preferences.player_style
|
||||||
preferred_captions ||= preferences.captions
|
preferred_captions ||= preferences.captions
|
||||||
quality ||= preferences.quality
|
quality ||= preferences.quality
|
||||||
|
quality_dash ||= preferences.quality_dash
|
||||||
related_videos ||= preferences.related_videos.to_unsafe
|
related_videos ||= preferences.related_videos.to_unsafe
|
||||||
speed ||= preferences.speed
|
speed ||= preferences.speed
|
||||||
video_loop ||= preferences.video_loop.to_unsafe
|
video_loop ||= preferences.video_loop.to_unsafe
|
||||||
@ -1077,6 +1080,7 @@ def process_video_params(query, preferences)
|
|||||||
player_style ||= CONFIG.default_user_preferences.player_style
|
player_style ||= CONFIG.default_user_preferences.player_style
|
||||||
preferred_captions ||= CONFIG.default_user_preferences.captions
|
preferred_captions ||= CONFIG.default_user_preferences.captions
|
||||||
quality ||= CONFIG.default_user_preferences.quality
|
quality ||= CONFIG.default_user_preferences.quality
|
||||||
|
quality_dash ||= CONFIG.default_user_preferences.quality_dash
|
||||||
related_videos ||= CONFIG.default_user_preferences.related_videos.to_unsafe
|
related_videos ||= CONFIG.default_user_preferences.related_videos.to_unsafe
|
||||||
speed ||= CONFIG.default_user_preferences.speed
|
speed ||= CONFIG.default_user_preferences.speed
|
||||||
video_loop ||= CONFIG.default_user_preferences.video_loop.to_unsafe
|
video_loop ||= CONFIG.default_user_preferences.video_loop.to_unsafe
|
||||||
@ -1129,6 +1133,7 @@ def process_video_params(query, preferences)
|
|||||||
player_style: player_style,
|
player_style: player_style,
|
||||||
preferred_captions: preferred_captions,
|
preferred_captions: preferred_captions,
|
||||||
quality: quality,
|
quality: quality,
|
||||||
|
quality_dash: quality_dash,
|
||||||
raw: raw,
|
raw: raw,
|
||||||
region: region,
|
region: region,
|
||||||
related_videos: related_videos,
|
related_videos: related_videos,
|
||||||
|
@ -57,6 +57,17 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<% if !CONFIG.disabled?("dash") %>
|
||||||
|
<div class="pure-control-group">
|
||||||
|
<label for="quality_dash"><%= translate(locale, "Preferred dash video quality: ") %></label>
|
||||||
|
<select name="quality_dash" id="quality_dash">
|
||||||
|
<% {"auto", "best", "worst"}.each do |option| %>
|
||||||
|
<option value="<%= option %>" <% if preferences.quality_dash == option %> selected <% end %>><%= translate(locale, option) %></option>
|
||||||
|
<% end %>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<div class="pure-control-group">
|
<div class="pure-control-group">
|
||||||
<label for="volume"><%= translate(locale, "Player volume: ") %></label>
|
<label for="volume"><%= translate(locale, "Player volume: ") %></label>
|
||||||
<input name="volume" id="volume" data-onrange="update_volume_value" type="range" min="0" max="100" step="5" value="<%= preferences.volume %>">
|
<input name="volume" id="volume" data-onrange="update_volume_value" type="range" min="0" max="100" step="5" value="<%= preferences.volume %>">
|
||||||
|
Loading…
Reference in New Issue
Block a user