|
|
@ -71,9 +71,9 @@ namespace QuickPlay
|
|
|
|
[NonSerialized]
|
|
|
|
[NonSerialized]
|
|
|
|
public static readonly AppConfiguration defaultConfiguration = new AppConfiguration
|
|
|
|
public static readonly AppConfiguration defaultConfiguration = new AppConfiguration
|
|
|
|
{
|
|
|
|
{
|
|
|
|
playerConfigUrl = "file:///dev/null",
|
|
|
|
playerConfigUrl = "http://www.ms.mff.cuni.cz/~turinskp/znelky.ini",
|
|
|
|
};
|
|
|
|
};
|
|
|
|
public PlayerConfiguration GetPlayerConfig()
|
|
|
|
public async Task<PlayerConfiguration> GetPlayerConfig()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
IPlayerConfigurationProvider cfgProvider;
|
|
|
|
IPlayerConfigurationProvider cfgProvider;
|
|
|
|
if (playerConfigUrl.StartsWith("http:") || playerConfigUrl.StartsWith("https:"))
|
|
|
|
if (playerConfigUrl.StartsWith("http:") || playerConfigUrl.StartsWith("https:"))
|
|
|
@ -84,11 +84,13 @@ namespace QuickPlay
|
|
|
|
string filename = playerConfigUrl.Substring("file://".Length);
|
|
|
|
string filename = playerConfigUrl.Substring("file://".Length);
|
|
|
|
var reader = new StreamReader(filename);
|
|
|
|
var reader = new StreamReader(filename);
|
|
|
|
cfgProvider = new FileConfigurationProvider(reader);
|
|
|
|
cfgProvider = new FileConfigurationProvider(reader);
|
|
|
|
|
|
|
|
} else if (playerConfigUrl == "default") {
|
|
|
|
|
|
|
|
cfgProvider = new DummyConfigurationProvider();
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new InvalidOperationException("Schema of player config URL not supported");
|
|
|
|
throw new InvalidOperationException("Schema of player config URL not supported");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return cfgProvider.GetConfigurationAsync().Result; // Bad code, but hopefully we dont hang.
|
|
|
|
return await cfgProvider.GetConfigurationAsync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// We want to compare by values.
|
|
|
|
// We want to compare by values.
|
|
|
@ -116,10 +118,10 @@ namespace QuickPlay
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public class PlayerConfiguration
|
|
|
|
public class PlayerConfiguration
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public Dictionary<string, IPlayable> songs;
|
|
|
|
public Dictionary<string, IPlayable> songs = new Dictionary<string, IPlayable>();
|
|
|
|
public string playerName;
|
|
|
|
public string playerName = "";
|
|
|
|
public PlayerType playerType;
|
|
|
|
public PlayerType playerType;
|
|
|
|
public string playerConnectionDetails; // This is opaque to this class, the player will make sense of it.
|
|
|
|
public string playerConnectionDetails = ""; // This is opaque to this class, the player will make sense of it.
|
|
|
|
|
|
|
|
|
|
|
|
public static PlayerConfiguration FromFile(StreamReader reader)
|
|
|
|
public static PlayerConfiguration FromFile(StreamReader reader)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -199,7 +201,15 @@ namespace QuickPlay
|
|
|
|
|
|
|
|
|
|
|
|
sealed class DummyConfigurationProvider : IPlayerConfigurationProvider
|
|
|
|
sealed class DummyConfigurationProvider : IPlayerConfigurationProvider
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public Task<PlayerConfiguration> GetConfigurationAsync() => null;
|
|
|
|
public Task<PlayerConfiguration> GetConfigurationAsync()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
PlayerConfiguration cfg = new PlayerConfiguration();
|
|
|
|
|
|
|
|
cfg.playerType = PlayerType.MPD;
|
|
|
|
|
|
|
|
cfg.playerName = "Dummy player";
|
|
|
|
|
|
|
|
cfg.playerConnectionDetails = "127.0.0.1";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Task.FromResult(cfg);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class Song: IPlayable
|
|
|
|
class Song: IPlayable
|
|
|
|