From d2e57ccc6f4f6d21ffe15188d50da8ddefcfa25a Mon Sep 17 00:00:00 2001 From: Carey Metcalfe Date: Tue, 15 Jan 2019 20:51:25 -0500 Subject: [PATCH] Add option to estimate the content length of streamed media Enabling this can help with seeking within transcoded media. Without knowing how big a file is, it's impossible to display an accurate progress bar. This option asks the server to send a "Content-Length" header with a guess (based on bitrate and song length) of how big the streamed file is going to be, enabling a progress bar to be shown. This reliably works with CBR transcodes, but can have issues with VBR as the server doesn't know how big the file will be before it's transcoded. If the server estimates incorrectly then songs could stop playing before they actually finish or cause other glitches. For the most part servers are pretty good with their estimates and being able to seek in a transcoded stream as it downloads is a substantial UX improvement so the option is enabled by default. --- app/common/model-service.js | 6 ++++++ app/settings/settings-service.js | 2 ++ app/settings/settings.html | 9 ++++++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/common/model-service.js b/app/common/model-service.js index 848bb1f..b1feaa1 100644 --- a/app/common/model-service.js +++ b/app/common/model-service.js @@ -111,6 +111,9 @@ angular.module('jamstash.model', ['jamstash.utils']) if (suffix == 'ogg') { suffix = 'oga'; } var salt = Math.floor(Math.random() * 100000); url = globals.BaseURL() + '/stream.view?' + globals.BaseParams() + '&id=' + song.id + '&salt=' + salt; + if (globals.settings.EstimateLength){ + url += "&estimateContentLength=true"; + } return new model.Song(song.id, song.parent, track, title, artist, song.artistId, song.album, song.albumId, coverartthumb, coverartfull, song.duration, song.userRating, starred, suffix, specs, url, 0, description); }; @@ -147,6 +150,9 @@ angular.module('jamstash.model', ['jamstash.utils']) if (suffix == 'ogg') { suffix = 'oga'; } var salt = Math.floor(Math.random() * 100000); url = globals.BaseURL() + '/stream.view?' + globals.BaseParams() + '&id=' + song.streamId + '&salt=' + salt; + if (globals.settings.EstimateLength){ + url += "&estimateContentLength=true"; + } return new model.Song(song.streamId, song.parent, track, title, artist, song.artistId, album, song.albumId, coverartthumb, coverartfull, song.duration, song.userRating, starred, suffix, specs, url, 0, description); }; diff --git a/app/settings/settings-service.js b/app/settings/settings-service.js index 72c1a46..3c07e10 100644 --- a/app/settings/settings-service.js +++ b/app/settings/settings-service.js @@ -58,7 +58,9 @@ angular.module('jamstash.settings.service', []) AutoPlay: false, LoopQueue: false, Repeat: false, + // Advanced Debug: false, + EstimateLength: true, ShowQueue: false }; this.SavedCollections = []; diff --git a/app/settings/settings.html b/app/settings/settings.html index 4ab6768..4b674fa 100644 --- a/app/settings/settings.html +++ b/app/settings/settings.html @@ -46,10 +46,10 @@
- -
+ +
-
+
@@ -81,6 +81,9 @@
+
+ +