Skip to content

Commit

Permalink
Change MediaPlayer service to Singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
sabihoshi committed May 17, 2021
1 parent 77d263a commit 20cd8c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions GenshinLyreMidiPlayer.WPF/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ public Bootstrapper()

protected override void ConfigureIoC(IStyletIoCBuilder builder)
{
var level = ConfigurationUserLevel.PerUserRoamingAndLocal;
var config = ConfigurationManager.OpenExeConfiguration(level);
var config = ConfigurationManager
.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);

var path = Path.GetDirectoryName(config.FilePath);

if (!Directory.Exists(path))
Directory.CreateDirectory(path);

Expand Down Expand Up @@ -72,18 +71,19 @@ protected override void ConfigureIoC(IStyletIoCBuilder builder)
Task.Run(async () =>
{
var icon = Path.Combine(path!, "icon.png");
var uri = new Uri("pack://application:,,,/item_windsong_lyre.png");
const string name = "item_windsong_lyre.png";
var location = Path.Combine(path!, name);
var uri = new Uri($"pack://application:,,,/{name}");
var resource = Application.GetResourceStream(uri)!.Stream;
Image.FromStream(resource)
.Save(icon);
Image.FromStream(resource).Save(location);
var file = await StorageFile.GetFileFromPathAsync(icon);
var file = await StorageFile.GetFileFromPathAsync(location);
controls.DisplayUpdater.Thumbnail = RandomAccessStreamReference.CreateFromFile(file);
});
return player;
});
}).InSingletonScope();
}
}
}
2 changes: 1 addition & 1 deletion GenshinLyreMidiPlayer.WPF/GenshinLyreMidiPlayer.WPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<UseWPF>true</UseWPF>
<StartupObject>GenshinLyreMidiPlayer.WPF.App</StartupObject>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Version>1.10.2</Version>
<Version>1.10.3</Version>
<ApplicationIcon>item_windsong_lyre.ico</ApplicationIcon>
<Nullable>enable</Nullable>
<RepositoryUrl>https://github.com/sabihoshi/GenshinLyreMidiPlayer</RepositoryUrl>
Expand Down

0 comments on commit 20cd8c8

Please sign in to comment.