This commit is contained in:
Royce551 2022-04-16 15:48:36 -05:00
parent ca64bea422
commit 630ec1c72a
6 changed files with 40 additions and 13 deletions

View file

@ -1,3 +1,5 @@
using System;
using System.IO;
using Avalonia; using Avalonia;
using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
@ -8,6 +10,17 @@ namespace FRESHMusicPlayer
{ {
public class App : Application public class App : Application
{ {
public static string DataFolderLocation
{
get
{
if (Directory.Exists("Data")) return "Data";
var applicationData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
if (applicationData == "") return "Data"; // apparently can happen on macos? just fall back to standalone mode
else return Path.Combine(applicationData, "FRESHMusicPlayer");
}
}
public override void Initialize() public override void Initialize()
{ {
AvaloniaXamlLoader.Load(this); AvaloniaXamlLoader.Load(this);

View file

@ -11,7 +11,8 @@
<Company>Squid Grill</Company> <Company>Squid Grill</Company>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>DEBUG</DefineConstants> <DefineConstants>DEBUG;NET;NET6_0;NETCOREAPP</DefineConstants>
<WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Models\" /> <Folder Include="Models\" />
@ -23,6 +24,10 @@
<None Remove="Assets\queue.svg" /> <None Remove="Assets\queue.svg" />
<None Remove="Assets\search.svg" /> <None Remove="Assets\search.svg" />
<None Remove="Assets\settings.svg" /> <None Remove="Assets\settings.svg" />
<None Remove="FRESHMusicPlayer.Core" />
<None Remove="LiteDB" />
<None Remove="System.Composition" />
<None Remove="NAudio" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.13" /> <PackageReference Include="Avalonia" Version="0.10.13" />
@ -31,15 +36,23 @@
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.13" /> <PackageReference Include="Avalonia.ReactiveUI" Version="0.10.13" />
<PackageReference Include="Avalonia.Svg.Skia" Version="0.10.10" /> <PackageReference Include="Avalonia.Svg.Skia" Version="0.10.10" />
<PackageReference Include="DiscordRichPresence" Version="1.0.150" /> <PackageReference Include="DiscordRichPresence" Version="1.0.150" />
<PackageReference Include="FRESHMusicPlayer.Core" Version="4.0.1" />
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.3" /> <PackageReference Include="SixLabors.ImageSharp" Version="1.0.3" />
<PackageReference Include="Tmds.DBus" Version="0.9.1" /> <PackageReference Include="Tmds.DBus" Version="0.9.1" />
<PackageReference Include="z440.atl.core" Version="3.19.0" /> <PackageReference Include="z440.atl.core" Version="3.19.0" />
<PackageReference Include="LiteDB" Version="5.0.9" />
<PackageReference Include="System.Composition" Version="1.4.1" />
<PackageReference Include="NAudio" Version="1.10.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="SIADL.Avalonia"> <Reference Include="SIADL.Avalonia">
<HintPath>Dependencies\SIADL.Avalonia.dll</HintPath> <HintPath>Dependencies\SIADL.Avalonia.dll</HintPath>
</Reference> </Reference>
<Reference Include="FRESHMusicPlayer.Core">
<HintPath>..\..\..\freshmusicplayer-core\FRESHMusicPlayer.Player\FRESHMusicPlayer.Player\bin\Release\netstandard2.0\FRESHMusicPlayer.Core.dll</HintPath>
</Reference>
<Reference Include="FRESHMusicPlayer.Core">
<HintPath>..\..\..\..\..\..\Users\squid\Desktop\freshmusicplayer-core\FRESHMusicPlayer.Player\FmpBassBackend\bin\Release\netstandard2.0\FRESHMusicPlayer.Core.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Update="Properties\Resources.Designer.cs"> <Compile Update="Properties\Resources.Designer.cs">

View file

@ -11,10 +11,9 @@ namespace FRESHMusicPlayer.Handlers.Configuration
static ConfigurationHandler() static ConfigurationHandler()
{ {
savePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FRESHMusicPlayer", "Configuration", "FMP-Avalonia"); savePath = Path.Combine(App.DataFolderLocation, "Configuration", "FMP-Avalonia");
} }
public static async Task<ConfigurationFile> Read() public static async Task<ConfigurationFile> Read()
{ {
if (!File.Exists(Path.Combine(savePath, "config.json"))) if (!File.Exists(Path.Combine(savePath, "config.json")))

View file

@ -73,9 +73,9 @@ namespace FRESHMusicPlayer.ViewModels
Player = new(); Player = new();
StartThings(); StartThings();
#if DEBUG // allow multiple instances of FMP in debug (at the expense of stability with heavy library use) #if DEBUG // allow multiple instances of FMP in debug (at the expense of stability with heavy library use)
var library = new LiteDatabase($"Filename=\"{Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FRESHMusicPlayer", "database.fdb2")}\";Connection=shared"); var library = new LiteDatabase($"Filename=\"{Path.Combine(App.DataFolderLocation, "database.fdb2")}\";Connection=shared");
#elif !DEBUG #elif !DEBUG
var library = new LiteDatabase(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FRESHMusicPlayer", "database.fdb2")); var library = new LiteDatabase(Path.Combine(App.DataFolderLocation "database.fdb2"));
#endif #endif
Library = new Library(library); Library = new Library(library);
} }
@ -566,11 +566,11 @@ namespace FRESHMusicPlayer.ViewModels
{ {
if (Program.Config.AutoImportPaths.Count <= 0) return; // not really needed but prevents going through unneeded if (Program.Config.AutoImportPaths.Count <= 0) return; // not really needed but prevents going through unneeded
// effort (and showing the notification) // effort (and showing the notification)
//var notification = new Notification() //var notification = new Notification()
//{ //{
// ContentText = Properties.Resources.Notification_Scanning // ContentText = Properties.Resources.Notification_Scanning
//}; //};
//Notifications.Add(notification); //Notifications.Add(notification);
//var filesToImport = new List<string>(); //var filesToImport = new List<string>();
//var library = Library.Read(); //var library = Library.Read();
//await Task.Run(() => //await Task.Run(() =>

View file

@ -1,4 +1,4 @@
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Interactivity; using Avalonia.Interactivity;
@ -177,7 +177,9 @@ namespace FRESHMusicPlayer.Views
} }
private async void OnDragDrop(object sender, DragEventArgs e) private async void OnDragDrop(object sender, DragEventArgs e)
{ {
ViewModel.Player.Queue.Add(e.Data.GetFileNames().ToArray()); var paths = e.Data.GetFileNames().ToArray();
ViewModel.Library.Import(paths);
ViewModel.Player.Queue.Add(paths);
await ViewModel.Player.PlayAsync(); await ViewModel.Player.PlayAsync();
} }
} }