Jamstash/app/settings/settings-service.js
Carey Metcalfe d2e57ccc6f 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.
2019-02-22 21:24:16 -05:00

88 lines
2.8 KiB
JavaScript

/**
* jamstash.settings.service Module
*
* Houses Jamstash's global settings and a few utility functions.
*/
angular.module('jamstash.settings.service', [])
.service('globals', function () {
'use strict';
this.SearchTypes = [
{ id: 0, name: "Song" },
{ id: 1, name: "Album" },
{ id: 2, name: "Artist" }
];
this.Layouts = [
{ id: "grid", name: "Grid" },
{ id: "list", name: "List" }
];
this.AlbumSorts = [
{ id: "default", name: "Default Sort" },
{ id: "artist", name: "Artist" },
{ id: "album", name: "Album" },
{ id: "track", name: "Track" },
{ id: "createdate desc", name: "Date Added" }
];
this.settings = {
// Subsonic
/* Demo Server
Username: "android-guest"),
Password: "guest"),
Server: "http://subsonic.org/demo"),
*/
Url: "http://jamstash.com/#/archive/",
Username: "",
Password: "",
Server: "",
Timeout: 20000,
Protocol: "jsonp",
ApplicationName: "Jamstash",
ApiVersion: "1.6.0",
AutoPlaylists: "",
AutoPlaylistSize: 25,
AutoAlbumSize: 15,
// General
HideAZ: false,
ScrollTitle: true,
NotificationSong: true,
NotificationNowPlaying: false,
SaveTrackPosition: false,
ForceFlash: false,
Theme: "Default",
DefaultLibraryLayout: this.Layouts[0],
DefaultSearchType: this.SearchTypes[0],
DefaultAlbumSort: this.AlbumSorts[0],
DefaultArchiveAlbumSort: "date desc",
Jukebox: false,
AutoPlay: false,
LoopQueue: false,
Repeat: false,
// Advanced
Debug: false,
EstimateLength: true,
ShowQueue: false
};
this.SavedCollections = [];
this.Player1 = '#playdeck_1';
this.archiveUrl = 'https://archive.org/';
this.ChangeLog = null;
this.Messages = [];
this.BaseURL = function () { return this.settings.Server + '/rest'; };
this.BaseParams = function () { return 'u=' + this.settings.Username + '&p=' + this.settings.Password + '&f=' + this.settings.Protocol + '&v=' + this.settings.ApiVersion + '&c=' + this.settings.ApplicationName; };
this.BaseJSONParams = function () { return 'u=' + this.settings.Username + '&p=' + this.settings.Password + '&f=json&v=' + this.settings.ApiVersion + '&c=' + this.settings.ApplicationName; };
})
.factory('json', ['$http', function ($http) { // Deferred loading
'use strict';
return {
getCollections: function (callback) {
$http.get('archive/json_collections.json').success(callback);
},
getChangeLog: function (callback) {
$http.get('common/json_changelog.json').success(callback);
}
};
}]);