From f7dea469f84fb82c8faf4415cc8b036d2a491fb3 Mon Sep 17 00:00:00 2001 From: Me on Windows Date: Sat, 19 Jun 2021 20:51:45 +0000 Subject: [PATCH] Allow both HTTP and local URLs for playerConfig --- QuickPlay/Configuration.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/QuickPlay/Configuration.cs b/QuickPlay/Configuration.cs index 9c45760..64abf2d 100644 --- a/QuickPlay/Configuration.cs +++ b/QuickPlay/Configuration.cs @@ -75,8 +75,19 @@ namespace QuickPlay }; public PlayerConfiguration GetPlayerConfig() { - // TODO: decide sensibly - var cfgProvider = new HttpConfigurationProvider(playerConfigUrl); + IPlayerConfigurationProvider cfgProvider; + if (playerConfigUrl.StartsWith("http:") || playerConfigUrl.StartsWith("https:")) + { + cfgProvider = new HttpConfigurationProvider(playerConfigUrl); + } else if (playerConfigUrl.StartsWith("file://")) + { + string filename = playerConfigUrl.Substring("file://".Length); + var reader = new StreamReader(filename); + cfgProvider = new FileConfigurationProvider(reader); + } else + { + throw new InvalidOperationException("Schema of player config URL not supported"); + } return cfgProvider.GetConfigurationAsync().Result; // Bad code, but hopefully we dont hang. }