mirror of
https://github.com/Sarsoo/Spotify.NET.git
synced 2024-12-24 23:16:28 +00:00
Added config for spotify local api
This commit is contained in:
parent
06adc23abb
commit
451d925d7d
@ -13,7 +13,12 @@ namespace SpotifyAPI.Local
|
|||||||
public string OauthKey { get; private set; }
|
public string OauthKey { get; private set; }
|
||||||
public string CfidKey { get; private set; }
|
public string CfidKey { get; private set; }
|
||||||
|
|
||||||
public const string Host = "127.0.0.1"; //Localhost since domain fails to resolve on some hosts
|
private SpotifyLocalAPIConfig _config;
|
||||||
|
|
||||||
|
public RemoteHandler(SpotifyLocalAPIConfig config)
|
||||||
|
{
|
||||||
|
_config = config;
|
||||||
|
}
|
||||||
|
|
||||||
internal Boolean Init()
|
internal Boolean Init()
|
||||||
{
|
{
|
||||||
@ -103,7 +108,7 @@ namespace SpotifyAPI.Local
|
|||||||
parameters += "&returnon=login%2Clogout%2Cplay%2Cpause%2Cerror%2Cap";
|
parameters += "&returnon=login%2Clogout%2Cplay%2Cpause%2Cerror%2Cap";
|
||||||
}
|
}
|
||||||
|
|
||||||
string address = "https://" + Host + ":4371/" + request + parameters;
|
string address = $"{_config.HostUrl}:{_config.Port}/{request}{parameters}";
|
||||||
string response = "";
|
string response = "";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -144,7 +149,7 @@ namespace SpotifyAPI.Local
|
|||||||
parameters += "&returnon=login%2Clogout%2Cplay%2Cpause%2Cerror%2Cap";
|
parameters += "&returnon=login%2Clogout%2Cplay%2Cpause%2Cerror%2Cap";
|
||||||
}
|
}
|
||||||
|
|
||||||
string address = "https://" + Host + ":4371/" + request + parameters;
|
string address = $"{_config.HostUrl}:{_config.Port}/{request}{parameters}";
|
||||||
string response = "";
|
string response = "";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -65,10 +65,16 @@ namespace SpotifyAPI.Local
|
|||||||
|
|
||||||
public SpotifyLocalAPI(int timerIntervall = 50)
|
public SpotifyLocalAPI(int timerIntervall = 50)
|
||||||
{
|
{
|
||||||
_rh = new RemoteHandler();
|
_rh = new RemoteHandler(new SpotifyLocalAPIConfig());
|
||||||
AttachTimer(timerIntervall);
|
AttachTimer(timerIntervall);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SpotifyLocalAPI(SpotifyLocalAPIConfig config)
|
||||||
|
{
|
||||||
|
_rh = new RemoteHandler(config);
|
||||||
|
AttachTimer(config.TimerInterval);
|
||||||
|
}
|
||||||
|
|
||||||
private void AttachTimer(int intervall)
|
private void AttachTimer(int intervall)
|
||||||
{
|
{
|
||||||
_eventTimer = new Timer
|
_eventTimer = new Timer
|
||||||
|
12
SpotifyAPI/Local/SpotifyLocalAPIConfig.cs
Normal file
12
SpotifyAPI/Local/SpotifyLocalAPIConfig.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
namespace SpotifyAPI.Local
|
||||||
|
{
|
||||||
|
// ReSharper disable once InconsistentNaming
|
||||||
|
public class SpotifyLocalAPIConfig
|
||||||
|
{
|
||||||
|
public int TimerInterval { get; set; } = 50;
|
||||||
|
|
||||||
|
public string HostUrl { get; set; } = "https://127.0.0.1";
|
||||||
|
|
||||||
|
public int Port { get; set; } = 4371;
|
||||||
|
}
|
||||||
|
}
|
@ -59,6 +59,7 @@
|
|||||||
<SubType>Component</SubType>
|
<SubType>Component</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Local\Models\SpotifyUri.cs" />
|
<Compile Include="Local\Models\SpotifyUri.cs" />
|
||||||
|
<Compile Include="Local\SpotifyLocalAPIConfig.cs" />
|
||||||
<Compile Include="Local\VolumeMixerControl.cs" />
|
<Compile Include="Local\VolumeMixerControl.cs" />
|
||||||
<Compile Include="Web\Auth\WebAPIFactory.cs" />
|
<Compile Include="Web\Auth\WebAPIFactory.cs" />
|
||||||
<Compile Include="Web\Enums\RepeatState.cs" />
|
<Compile Include="Web\Enums\RepeatState.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user