// called by MusicBee when the user clicks Apply or Save in the MusicBee Preferences screen. // its up to you to figure out whether anything has changed and needs updating public void SaveSettings() { var settings = new SubsonicSettings { Host = _host.Text, Port = _port.Text, BasePath = _basePath.Text, Username = _username.Text, Password = _password.Text, Transcode = _transcode.Checked, Protocol = _protocol.SelectedItem.ToString().Equals("HTTP") ? SubsonicSettings.ConnectionProtocol.Http : SubsonicSettings.ConnectionProtocol.Https, Auth = _authMethodBox.SelectedIndex.Equals(0) ? SubsonicSettings.AuthMethod.Token : SubsonicSettings.AuthMethod.HexPass, //Null reference. Issue #36 - https://github.com/midwan/MB_SubSonic/issues/36. If there is no bitrate, set it to a default. BitRate = String.IsNullOrEmpty((String)_bitRate.SelectedItem) ? "128K" : _bitRate.SelectedItem.ToString() }; var setHostSuccess = Subsonic.SetHost(settings); if (setHostSuccess) { DeleteCacheFile(); Refresh(); return; } var error = Subsonic.GetError(); var message = error?.Message; if (!string.IsNullOrEmpty(message)) { MessageBox.Show(_host, $@"Error: {message}", @"Subsonic Plugin", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public Exception GetError() { return(Subsonic.GetError()); }