Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

Commit

Permalink
1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
qedsd committed Jun 6, 2021
1 parent 7b88732 commit e030600
Show file tree
Hide file tree
Showing 15 changed files with 350 additions and 66 deletions.
2 changes: 1 addition & 1 deletion MyNCMusic/Helper/LoginHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static LoginRoot LoginAccount()
static LoginStatus GetLoginStatus()
{
string result = Http.Get(ConfigService.ApiUri + "/login/status");
return JsonConvert.DeserializeObject<LoginStatus>(result);
return result==null?null:JsonConvert.DeserializeObject<LoginStatus>(result);
}
}
}
5 changes: 3 additions & 2 deletions MyNCMusic/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
</Grid.RowDefinitions>
<Grid Grid.Row="0"
Grid.RowSpan="2"
Margin="0,-1,0,0">
Margin="0,-1,0,0"
>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
Expand All @@ -40,7 +41,7 @@
<Grid.Background>
<AcrylicBrush BackgroundSource="Backdrop"
TintColor="Black"
TintOpacity="0.3"/>
TintOpacity="0.4"/>
</Grid.Background>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300"/>
Expand Down
17 changes: 15 additions & 2 deletions MyNCMusic/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public MainPage()
_mediaPlayer.MediaEnded += _mediaPlayer_MediaEnded;
_mediaPlayer.SourceChanged += _mediaPlayer_SourceChanged;


//接管系统播放音频控制
_mediaPlayer.CommandManager.NextBehavior.EnablingRule = MediaCommandEnablingRule.Always;
_mediaPlayer.CommandManager.PreviousBehavior.EnablingRule = MediaCommandEnablingRule.Always;
Expand All @@ -97,6 +98,8 @@ public MainPage()
Window.Current.SetTitleBar(MyTitleBar);
}



private async void PlayingService_OnPlayingRadioChanged()
{
ChangeImage();
Expand Down Expand Up @@ -210,6 +213,7 @@ await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
{
isSliderChangedFromAuto = true;
Slider_play.Value = sender.Position.TotalSeconds;

TextBlock_currentTime.Text = OtherHelper.GetDt((int)sender.Position.TotalSeconds);
if ((Application.Current as App).playingPage != null)
(Application.Current as App).playingPage.ChangeLyricPosition(sender.Position.TotalMilliseconds);
Expand All @@ -220,6 +224,7 @@ private async void _mediaPlayer_MediaEnded(MediaPlayer sender, object args)
{
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
{
_mediaTimelineController.Pause();
if (PlayingService.IsPlayingSong)
PlayingService.PlayNextSongs();
else
Expand Down Expand Up @@ -283,8 +288,11 @@ async void GetLastPlayingInfo()
UpDatePlayOrderStateIcon();
if (PlayingService.PlayingSongUrlRoot != null)
{
_mediaSource = await Task.Run(() => MediaSource.CreateFromUri(new Uri(PlayingService.PlayingSongUrlRoot.data.First().url)));
SongUrlRoot songUrlRoot = SongService.GetMusicUrl(PlayingService.PlayingSongUrlRoot.data.First().id);
//_mediaSource = await Task.Run(() => MediaSource.CreateFromUri(new Uri(PlayingService.PlayingSongUrlRoot.data.First().url)));
_mediaSource = await Task.Run(() => MediaSource.CreateFromUri(new Uri(songUrlRoot.data.First().url)));
_mediaSource.OpenOperationCompleted += _mediaSource_OpenOperationCompleted;
_mediaSource.StateChanged += _mediaSource_StateChanged;
_mediaPlaybackItem = new MediaPlaybackItem(_mediaSource);
_mediaPlayer.Source = _mediaPlaybackItem;

Expand All @@ -293,6 +301,11 @@ async void GetLastPlayingInfo()
}
}

private void _mediaSource_StateChanged(MediaSource sender, MediaSourceStateChangedEventArgs args)
{

}


/// <summary>
/// 启动时获取应用设置
Expand All @@ -310,7 +323,7 @@ void GetSetting()
private async void _mediaSource_OpenOperationCompleted(MediaSource sender, MediaSourceOpenOperationCompletedEventArgs args)
{
_duration = sender.Duration.GetValueOrDefault();

//_mediaTimelineController.Duration = _duration;
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
{
Slider_play.Maximum = _duration.TotalSeconds;
Expand Down
7 changes: 7 additions & 0 deletions MyNCMusic/MyNCMusic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@
<Compile Include="Views\Recommendation.xaml.cs">
<DependentUpon>Recommendation.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SettingPage.xaml.cs">
<DependentUpon>SettingPage.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
Expand Down Expand Up @@ -316,6 +319,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\SettingPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
Expand Down
2 changes: 2 additions & 0 deletions MyNCMusic/Services/ConfigService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using MyNCMusic.Helper;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Text;
Expand All @@ -11,6 +12,7 @@
namespace MyNCMusic.Services
{
[Serializable]
[Bindable(true)]
public class ConfigService
{
public static StorageFolder Folder = ApplicationData.Current.LocalFolder;
Expand Down
42 changes: 36 additions & 6 deletions MyNCMusic/Services/PlayingService .cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using MyNCMusic.Helper;
using MyNCMusic.Model;
using MyNCMusic.MyUserControl;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
Expand Down Expand Up @@ -189,8 +190,17 @@ public static async Task<bool> ChangePlayingSong(long playingSongId, List<SongsI
b=await PreparePlayingSong(PlayingSongId);
else
b=await PreparePlayingSong(PlayingSongId, songsItem);
PlayingListToBaseObject(PlayingSongList);
WhenPlayingSongChange();
if (!b)
{
NotifyPopup notifyPopup = new NotifyPopup("获取音乐失败");
notifyPopup.Show();
}
else
{

PlayingListToBaseObject(PlayingSongList);
WhenPlayingSongChange();
}
return b;
}
public static async Task<bool> ChangePlayingSong(long playingSongId, SongsItem songsItem = null)
Expand Down Expand Up @@ -483,7 +493,12 @@ public static async void PlayNextSongs()
return;
}
}
await PlayingService.ChangePlayingSong(willPlayId, PlayingService.PlayingSongList);
for (int i = 0; i < 5; i++)
{
if (await ChangePlayingSong(willPlayId, PlayingSongList))
break;
}
NotifyPopup notifyPopup = new NotifyPopup("多次获取音乐失败,停止播放");
}

/// <summary>
Expand All @@ -494,7 +509,12 @@ public static async void PlayLastSongs()
if (PlayedSongId!=null&&PlayedSongId.Count > 1)//上一个是当前歌曲,所以要上上一个
{
PlayedSongId.Remove(PlayedSongId.Last());//移出当前
await PlayingService.ChangePlayingSong(PlayedSongId.Last(), PlayingService.PlayedSongList);
for (int i = 0; i < 5; i++)
{
if (await ChangePlayingSong(PlayedSongId.Last(), PlayingService.PlayedSongList))
break;
}
NotifyPopup notifyPopup = new NotifyPopup("多次获取音乐失败,停止播放");
}
}

Expand Down Expand Up @@ -555,7 +575,12 @@ public static async void PlayNextRadio()
return;
}
}
await ChangePlayingRadio(willPlayId, PlayingRadioList);
for (int i = 0; i < 5; i++)
{
if (await ChangePlayingRadio(willPlayId, PlayingRadioList))
break;
}
NotifyPopup notifyPopup = new NotifyPopup("多次获取音乐失败,停止播放");
}

/// <summary>
Expand All @@ -566,7 +591,12 @@ public static async void PlayLastRadio()
if (PlayedRadioId!=null&&PlayedRadioId.Count > 1)//上一个是当前电台,所以要上上一个
{
PlayedRadioId.Remove(PlayedRadioId.Last());//移出当前
await ChangePlayingRadio(PlayedRadioId.Last(), PlayedRadioList);
for (int i = 0; i < 5; i++)
{
if (await ChangePlayingRadio(PlayedRadioId.Last(), PlayedRadioList))
break;
}
NotifyPopup notifyPopup = new NotifyPopup("多次获取音乐失败,停止播放");
}
}

Expand Down
8 changes: 5 additions & 3 deletions MyNCMusic/Views/Home.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Animation;
using Windows.UI.Xaml.Navigation;

// https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板
Expand Down Expand Up @@ -48,7 +49,7 @@ private async void Home_Loaded(object sender, RoutedEventArgs e)
if (!isFirstTimeLoad)
return;
isFirstTimeLoad = false;
AcrylicBrush_mainFrame.TintColor = MainPage.backgroundBrush.Color;//acrylic背景颜色
//AcrylicBrush_mainFrame.TintColor = MainPage.backgroundBrush.Color;//acrylic背景颜色
TextBox_account.Text = ConfigService.PhoneOrEmail;
PasswordBox_password.Password = ConfigService.Password;
TextBox_serverIP.Text = ConfigService.ApiUri.ToString();
Expand Down Expand Up @@ -133,9 +134,10 @@ private void Button_myCollection_Click(object sender, RoutedEventArgs e)
}
}

private async void Button_setting_Click(object sender, RoutedEventArgs e)
private void Button_setting_Click(object sender, RoutedEventArgs e)
{
await ContentDialog_setting.ShowAsync();
//await ContentDialog_setting.ShowAsync();
Frame_main.Navigate(typeof(SettingPage),null, new DrillInNavigationTransitionInfo());
}

private async void ContentDialog_setting_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
Expand Down
30 changes: 20 additions & 10 deletions MyNCMusic/Views/MyMusicList.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,17 @@
<DataTemplate x:DataType="model:PlaylistItem">
<StackPanel Width="160" Background="{ThemeResource SystemControlAcrylicElementBrush}"
Margin="4"
>
CornerRadius="4">
<Image Source="{x:Bind coverImgUrl,Converter={StaticResource ReturnImageUriWithParam_160}}" Height="160" Width="160"/>
<TextBlock Text="{x:Bind name}" TextWrapping="WrapWholeWords"
Height="40"
Margin="4"
HorizontalAlignment="Center"/>
<Grid Height="40"
Margin="4"
>
<TextBlock Text="{x:Bind name}" TextWrapping="WrapWholeWords"
HorizontalAlignment="Center"
VerticalAlignment="Center"
MaxHeight="40"
ToolTipService.ToolTip="{x:Bind name}"/>
</Grid>
</StackPanel>
</DataTemplate>
</controls:AdaptiveGridView.ItemTemplate>
Expand All @@ -68,12 +73,17 @@
<DataTemplate x:DataType="model:PlaylistItem">
<StackPanel Width="160" Background="{ThemeResource SystemControlAcrylicElementBrush}"
Margin="4"
>
CornerRadius="4">
<Image Source="{x:Bind coverImgUrl,Converter={StaticResource ReturnImageUriWithParam_160}}" Height="160" Width="160"/>
<TextBlock Text="{x:Bind name}" TextWrapping="WrapWholeWords"
Height="40"
Margin="4"
HorizontalAlignment="Center"/>
<Grid Height="40"
Margin="4"
>
<TextBlock Text="{x:Bind name}" TextWrapping="WrapWholeWords"
HorizontalAlignment="Center"
VerticalAlignment="Center"
MaxHeight="40"
ToolTipService.ToolTip="{x:Bind name}"/>
</Grid>
</StackPanel>
</DataTemplate>
</controls:AdaptiveGridView.ItemTemplate>
Expand Down
7 changes: 7 additions & 0 deletions MyNCMusic/Views/MyMusicList.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MyNCMusic.Model;
using MyNCMusic.MyUserControl;
using MyNCMusic.Services;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -42,6 +43,12 @@ private async void MyMusicList_Loaded(object sender, RoutedEventArgs e)
playlistItems_created = new ObservableCollection<PlaylistItem>();
playlistItems_subscribed = new ObservableCollection<PlaylistItem>();
MyPlaylistRoot myPlaylistRoot = await Task.Run(() => PlaylistService.GetMyPlaylist());
if(myPlaylistRoot==null|| myPlaylistRoot.playlist==null)
{
NotifyPopup notifyPopup = new NotifyPopup("获取失败");
notifyPopup.Show();
return;
}
foreach (var temp in myPlaylistRoot.playlist)
{
if (temp.subscribed == "true")
Expand Down
4 changes: 2 additions & 2 deletions MyNCMusic/Views/PlayListDetai.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ private void AutoSuggestBox_search_TextChanged(AutoSuggestBox sender, AutoSugges
ListBox_musicDetail.ItemsSource = musicDetailRootSource.songs;
else
{
var list = musicDetailRootSource.songs.Where(p => p.Name.Contains(sender.Text)) as System.Collections.ObjectModel.ObservableCollection<SongsItem>;
if (list != null && list.Count != 0)
var list = musicDetailRootSource.songs.Where(p => p.Name.Contains(sender.Text));
if (list != null && list.Count() != 0)
{
ListBox_musicDetail.ItemsSource = list;
}
Expand Down
3 changes: 2 additions & 1 deletion MyNCMusic/Views/PlayingPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@
<Image x:Name="Image_album"
Height="180"
Width="180"
Grid.Column="0"/>
Grid.Column="0"
/>
<Grid Grid.Column="1" Margin="20,20,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
Expand Down
37 changes: 26 additions & 11 deletions MyNCMusic/Views/Recommendation.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,18 @@
<DataTemplate x:DataType="model:Recommend">
<StackPanel Width="160" Background="{ThemeResource SystemControlAcrylicElementBrush}"
Margin="4"
>
CornerRadius="4">
<Image Source="{x:Bind picUrl,Converter={StaticResource ReturnImageUriWithParam_160}}" Height="160" Width="160"/>
<TextBlock Text="{x:Bind name}" TextWrapping="WrapWholeWords"
Height="40"
Margin="4"
HorizontalAlignment="Center"/>
<Grid Height="40"
Margin="4"
>
<TextBlock Text="{x:Bind name}" TextWrapping="WrapWholeWords"
HorizontalAlignment="Center"
VerticalAlignment="Center"
MaxHeight="40"
ToolTipService.ToolTip="{x:Bind name}"/>
</Grid>

</StackPanel>
</DataTemplate>
</controls:AdaptiveGridView.ItemTemplate>
Expand Down Expand Up @@ -288,6 +294,7 @@
</PivotItem.Header>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
Expand All @@ -297,7 +304,10 @@
Style="{StaticResource AutoSuggestBoxStyle1}"
QuerySubmitted="AutoSuggestBox_search_QuerySubmitted"
/>
<Pivot Grid.Row="1" Name="Pivot_search"
<ProgressBar x:Name="ProgressBar_Searching" Visibility="Collapsed" IsIndeterminate="True" ShowPaused="False"
Grid.Row="1"
/>
<Pivot Grid.Row="2" Name="Pivot_search"
SelectionChanged="Pivot_search_SelectionChanged">
<PivotItem Tag="1">
<PivotItem.Header>
Expand Down Expand Up @@ -488,12 +498,17 @@
<DataTemplate x:DataType="model:PlaylistItem">
<StackPanel Width="160" Background="{ThemeResource SystemControlAcrylicElementBrush}"
Margin="4"
>
CornerRadius="4">
<Image Source="{x:Bind coverImgUrl,Converter={StaticResource ReturnImageUriWithParam_160}}" Height="160" Width="160"/>
<TextBlock Text="{x:Bind name}" TextWrapping="WrapWholeWords"
Height="40"
Margin="4"
HorizontalAlignment="Center"/>
<Grid Height="40"
Margin="4"
>
<TextBlock Text="{x:Bind name}" TextWrapping="WrapWholeWords"
HorizontalAlignment="Center"
VerticalAlignment="Center"
MaxHeight="40"
ToolTipService.ToolTip="{x:Bind name}"/>
</Grid>
</StackPanel>
</DataTemplate>
</controls:AdaptiveGridView.ItemTemplate>
Expand Down
Loading

0 comments on commit e030600

Please sign in to comment.