Skip to content

Commit

Permalink
Merge pull request #68 from HyPlayer/dep/submoudules
Browse files Browse the repository at this point in the history
[Feat] 实现GetCoverAsync
  • Loading branch information
Raspberry-Monster authored Jul 14, 2024
2 parents ffad1b5 + f330344 commit 6c1cbd3
Show file tree
Hide file tree
Showing 54 changed files with 285 additions and 501 deletions.
11 changes: 6 additions & 5 deletions src/HyPlayer.App/App.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>HyPlayer</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest>
Expand All @@ -18,6 +18,7 @@
<Company>HyPlayer Team</Company>
<Product>HyPlayer</Product>
<UserSecretsId>3e757a82-9759-482b-851c-170ec2aa99dc</UserSecretsId>
<SupportedOSPlatformVersion>10.0.19041.0</SupportedOSPlatformVersion>
</PropertyGroup>


Expand Down Expand Up @@ -158,10 +159,10 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\HyPlayer.NeteaseProvider\HyPlayer.NeteaseApi\HyPlayer.NeteaseApi.csproj" />
<ProjectReference Include="..\HyPlayer.NeteaseProvider\HyPlayer.NeteaseProvider\HyPlayer.NeteaseProvider.csproj" />
<ProjectReference Include="..\HyPlayer.PlayCore\HyPlayer.PlayCore.Abstraction\HyPlayer.PlayCore.Abstraction.csproj" />
<ProjectReference Include="..\HyPlayer.PlayCore\HyPlayer.PlayCore\HyPlayer.PlayCore.csproj" />
<ProjectReference Include="..\..\refs\HyPlayer.NeteaseProvider\HyPlayer.NeteaseApi\HyPlayer.NeteaseApi.csproj" />
<ProjectReference Include="..\..\refs\HyPlayer.NeteaseProvider\HyPlayer.NeteaseProvider\HyPlayer.NeteaseProvider.csproj" />
<ProjectReference Include="..\..\refs\HyPlayer.PlayCore\HyPlayer.PlayCore.Abstraction\HyPlayer.PlayCore.Abstraction.csproj" />
<ProjectReference Include="..\..\refs\HyPlayer.PlayCore\HyPlayer.PlayCore\HyPlayer.PlayCore.csproj" />
</ItemGroup>

</Project>
39 changes: 18 additions & 21 deletions src/HyPlayer.App/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using WinUIEx;
using System;
using System.IO;
using System.Threading.Tasks;
using Windows.Storage;
using Depository.Abstraction.Interfaces;
using Depository.Core;
using Depository.Extensions;
using HyPlayer.Extensions.DependencyInjectionExtensions;
using HyPlayer.Extensions.Helpers;
using HyPlayer.Interfaces.Views;
using HyPlayer.Services;
using HyPlayer.PlayCore;
using HyPlayer.PlayCore.Abstraction;
using Microsoft.UI.Dispatching;
using HyPlayer.Services;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using System;
using System.Threading.Tasks;
using DispatcherQueue = Windows.System.DispatcherQueue;
using Window = HyPlayer.Views.Window;
using XamlWindow = Microsoft.UI.Xaml.Window;
using Pages = HyPlayer.Views.Pages;
using HyPlayer.ViewModels;
using HyPlayer.Extensions.Helpers;
using XamlWindow = Microsoft.UI.Xaml.Window;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
Expand Down Expand Up @@ -53,9 +47,9 @@ public static T GetService<T>()
return (Current as App)!.DispatcherQueue;
}

public static IDepository? GetDIContainer()
public static IDepository GetDIContainer()
{
return (Current as App)!.Depository;
return (Current as App)!.Depository!;
}

/// <summary>
Expand All @@ -79,14 +73,14 @@ protected override async void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventA
ConfigureServices();
await ConfigurePlayCore();
window = WindowHelper.CreateWindow();
if(window != null)
{
if (window != null)
{
NavigateToRootPage(args);

window?.Activate();
}
}

private void ConfigureServices()
{
Depository?.AddMvvm();
Expand All @@ -98,13 +92,16 @@ private async Task ConfigurePlayCore()
{
Depository?.AddSingleton<PlayCoreBase, Chopin>();
var playCore = Depository?.Resolve<PlayCoreBase>();
await playCore.RegisterMusicProviderAsync(typeof(NeteaseProvider.NeteaseProvider));
if (playCore != null)
{
await playCore.RegisterMusicProviderAsync(typeof(NeteaseProvider.NeteaseProvider));
}
}

private void NavigateToRootPage(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
{
GetService<INavigationService>().NavigateTo(typeof(Pages.HomePage));
}

}
}
10 changes: 5 additions & 5 deletions src/HyPlayer.App/Extensions/CoverExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
using HyPlayer.NeteaseProvider.Models;
using HyPlayer.PlayCore.Abstraction.Interfaces.ProvidableItem;
using HyPlayer.PlayCore.Abstraction.Models;
using HyPlayer.PlayCore.Abstraction.Models.Resources;
using System;

namespace HyPlayer.Extensions;

public static class CoverExtensions
{
public static string? GetCoverUrl(this IHasCover item, int pixelX, int pixelY)
public static Uri? GetCoverUrl(this IHasCover item, int pixelX, int pixelY)
{
var coverResource = item.GetCoverAsync(new ImageResourceQualityTag(pixelX, pixelY)).GetAwaiter().GetResult();
if (coverResource is not IResourceResultOf<string> resourceResult)
var coverResource = item.GetCoverAsync(new NeteaseImageResourceQualityTag(pixelX, pixelY)).GetAwaiter().GetResult();
if (coverResource is not NeteaseImageResourceResult neteaseResourceResult)
return null;
return resourceResult
return neteaseResourceResult
.GetResourceAsync()
.GetAwaiter().GetResult();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Reflection;
using Depository.Abstraction.Enums;
using Depository.Abstraction.Interfaces;
using Depository.Extensions;
using System.Reflection;

namespace HyPlayer.Extensions.DependencyInjectionExtensions;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System.Reflection;
using Depository.Abstraction.Enums;
using Depository.Abstraction.Interfaces;
using HyPlayer.Interfaces;
using HyPlayer.Interfaces.ViewModels;
using System.Reflection;

namespace HyPlayer.Extensions.DependencyInjectionExtensions;

Expand Down
12 changes: 6 additions & 6 deletions src/HyPlayer.App/Extensions/Helpers/UIHelper.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
using System;
using System.Threading.Tasks;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using System;
using System.Threading.Tasks;

namespace HyPlayer.Extensions.Helpers
{
public class UIHelper
{
public static async Task<ContentDialogResult> ShowDialogAsync(ContentDialog dialog, XamlRoot xamlRoot)
{

dialog.DefaultButton = ContentDialogButton.Primary;
dialog.Style = (Style) App.Current.Resources["DefaultContentDialogStyle"];
dialog.Style = (Style)App.Current.Resources["DefaultContentDialogStyle"];
dialog.XamlRoot = xamlRoot;

var result = await dialog.ShowAsync();
return result;
}
Expand Down
19 changes: 7 additions & 12 deletions src/HyPlayer.App/Extensions/Helpers/WindowHelper.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
using Microsoft.UI.Xaml;
using HyPlayer.Views.Window;
using Microsoft.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.ApplicationModel;
using WinRT.Interop;
using HyPlayer.Views.Window;
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
using System.Collections.Generic;

namespace HyPlayer.Extensions.Helpers
{
Expand Down Expand Up @@ -44,7 +38,8 @@ static public Window CreateBlankWindow()

static public void TrackWindow(Window window)
{
window.Closed += (sender, args) => {
window.Closed += (sender, args) =>
{
_activeWindows.Remove(window);
};
_activeWindows.Add(window);
Expand Down Expand Up @@ -81,8 +76,8 @@ static public void InitializeTitleBarForWindow(Window window, bool isTallTitleBa
titleBar.ExtendsContentIntoTitleBar = true;
}

// A taller title bar is only supported when drawing a fully custom title bar
if (AppWindowTitleBar.IsCustomizationSupported() && titleBar.ExtendsContentIntoTitleBar)
// A taller title bar is only supported when drawing a fully custom title bar
if (AppWindowTitleBar.IsCustomizationSupported() && titleBar.ExtendsContentIntoTitleBar)
{
if (isTallTitleBar)
{
Expand Down
2 changes: 1 addition & 1 deletion src/HyPlayer.App/Interfaces/ViewModels/IScopedViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ namespace HyPlayer.Interfaces.ViewModels;

public interface IScopedViewModel : IViewModel
{

}
4 changes: 2 additions & 2 deletions src/HyPlayer.App/Interfaces/ViewModels/ISingletonViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace HyPlayer.Interfaces.ViewModels;

public interface ISingletonViewModel : IViewModel
public interface ISingletonViewModel : IViewModel
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ namespace HyPlayer.Interfaces.ViewModels;

public interface ITransientViewModel : IViewModel
{

}
2 changes: 1 addition & 1 deletion src/HyPlayer.App/Interfaces/ViewModels/IViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ namespace HyPlayer.Interfaces.ViewModels;

public interface IViewModel
{

}
4 changes: 2 additions & 2 deletions src/HyPlayer.App/Interfaces/Views/AppPage.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using Depository.Abstraction.Interfaces;
using Depository.Abstraction.Interfaces;
using Depository.Core;
using Depository.Extensions;
using HyPlayer.Interfaces.ViewModels;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using System;

namespace HyPlayer.Interfaces.Views;

Expand Down
6 changes: 3 additions & 3 deletions src/HyPlayer.App/Interfaces/Views/INavigationService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Navigation;
using System;

namespace HyPlayer.Interfaces.Views;

Expand All @@ -15,7 +15,7 @@ bool CanGoBack

Frame? Frame
{
get;
get;
}

bool NavigateTo(Type Page, object? parameter = null);
Expand Down
6 changes: 3 additions & 3 deletions src/HyPlayer.App/Interfaces/Views/ReactiveControlBase.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml;
using Depository.Abstraction.Interfaces;
using Depository.Abstraction.Interfaces;
using Depository.Core;
using Depository.Extensions;
using HyPlayer.Interfaces.ViewModels;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using System;

namespace HyPlayer.Interfaces.Views;
Expand Down
18 changes: 9 additions & 9 deletions src/HyPlayer.App/Services/NavigationService.cs
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
using Microsoft.UI.Xaml.Controls;
using HyPlayer.Interfaces.Views;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media.Animation;
using Microsoft.UI.Xaml.Navigation;
using System;
using HyPlayer.Interfaces.Views;

namespace HyPlayer.Services
{
internal class NavigationService : INavigationService
{
public bool CanGoBack => App.contentFrame.CanGoBack;
public bool CanGoBack => App.contentFrame!.CanGoBack;

public Frame? Frame => App.contentFrame;

public event NavigatedEventHandler? Navigated;

public bool GoBack()
{
if(CanGoBack)
if (CanGoBack)
{
Frame?.GoBack();
return true;
}
else return false;
}

public bool NavigateTo(Type Page, object parameter)
public bool NavigateTo(Type Page, object? parameter)
{
if (Frame != null)
{
return Frame.Navigate(Page, parameter, new SlideNavigationTransitionInfo { Effect = SlideNavigationTransitionEffect.FromRight });
}
else
else
{
return false;
return false;
}
}

public bool NavigateTo(Page Page, object parameter)
public bool NavigateTo(Page Page, object? parameter)
{
if (Frame != null)
{
return Frame.Navigate(typeof(Page), parameter, new SlideNavigationTransitionInfo { Effect = SlideNavigationTransitionEffect.FromRight });

}
else
{
Expand Down
10 changes: 2 additions & 8 deletions src/HyPlayer.App/Services/PageService.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
using HyPlayer.Views.Pages;
using Microsoft.UI.Xaml.Controls;
using HyPlayer.Interfaces.Views;
using HyPlayer.Views.Pages;
using System;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HyPlayer.Interfaces.Views;

namespace HyPlayer.Services
{
Expand Down
Loading

0 comments on commit 6c1cbd3

Please sign in to comment.