Skip to content

Commit

Permalink
Fixes And More (❁´◡`❁)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaKrotos committed Mar 12, 2024
1 parent 6bd9b48 commit 686625b
Show file tree
Hide file tree
Showing 11 changed files with 275 additions and 164 deletions.
56 changes: 26 additions & 30 deletions VK UI3/Controllers/AudioPlayer.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,14 @@ public int TrackPosition



public static VkNet.Model.Attachments.Audio _TrackDataThis
public static ExtendedAudio _TrackDataThis
{
get
{
if (iVKGetAudio != null)
if (iVKGetAudio.countTracks != 0)
{




return iVKGetAudio.GetTrackPlay().audio;
return iVKGetAudio.GetTrackPlay();

}
return _trackDataThis;
Expand All @@ -108,8 +104,8 @@ public static VkNet.Model.Attachments.Audio _TrackDataThis
}
}

private static VkNet.Model.Attachments.Audio _trackDataThis;
public VkNet.Model.Attachments.Audio TrackDataThis
private static ExtendedAudio _trackDataThis;
public ExtendedAudio TrackDataThis
{
get { return _TrackDataThis; }
}
Expand Down Expand Up @@ -143,13 +139,13 @@ public string Thumbnail
{
get
{
if (TrackDataThis == null) return "null";
if (TrackDataThis.Album == null) return "null";
return TrackDataThis.Album.Thumb.Photo600
?? TrackDataThis.Album.Thumb.Photo300
?? TrackDataThis.Album.Thumb.Photo270
?? TrackDataThis.Album.Thumb.Photo68
?? TrackDataThis.Album.Thumb.Photo34
if (TrackDataThis.audio == null) return "null";
if (TrackDataThis.audio.Album == null) return "null";
return TrackDataThis.audio.Album.Thumb.Photo600
?? TrackDataThis.audio.Album.Thumb.Photo300
?? TrackDataThis.audio.Album.Thumb.Photo270
?? TrackDataThis.audio.Album.Thumb.Photo68
?? TrackDataThis.audio.Album.Thumb.Photo34
?? "null";
}

Expand Down Expand Up @@ -302,7 +298,7 @@ private void CommandManager_NextReceived(MediaPlaybackCommandManager sender, Med
private void PlaybackSession_BufferedRangesChanged(MediaPlaybackSession sender, object args)
{
var a = (int)Math.Round(sender.NaturalDuration.TotalSeconds);
var b = TrackDataThis.Duration;
var b = TrackDataThis.audio.Duration;

if (Math.Abs(a - b) > 3)
{
Expand Down Expand Up @@ -361,7 +357,7 @@ private void PlaybackSession_PositionChanged(MediaPlaybackSession sender, object
private void MediaPlayer_MediaOpened(Windows.Media.Playback.MediaPlayer sender, object args)
{
// Код для выполнения при открытии медиафайла
TrackDuration = (int) TrackDataThis.Duration;
TrackDuration = (int) TrackDataThis.audio.Duration;
}
private void MediaPlayer_MediaFailed(Windows.Media.Playback.MediaPlayer sender, Windows.Media.Playback.MediaPlayerFailedEventArgs args)
{
Expand Down Expand Up @@ -415,16 +411,16 @@ private void MediaPlayer_SourceChanged(Windows.Media.Playback.MediaPlayer sender

var source = sender.Source as Windows.Media.Playback.MediaPlaybackItem;

TrackDuration = (int) TrackDataThis.Duration;
TrackDuration = (int) TrackDataThis.audio.Duration;


OnPropertyChanged(nameof(TrackDuration));
OnPropertyChanged(nameof(TrackPosition));
OnPropertyChanged(nameof(TrackDataThis));

changeImage.ChangeImageWithAnimation(Thumbnail);
changeText.ChangeTextWithAnimation(TrackDataThis.Artist);
changeText2.ChangeTextWithAnimation(TrackDataThis.Title);
changeText.ChangeTextWithAnimation(TrackDataThis.audio.Artist);
changeText2.ChangeTextWithAnimation(TrackDataThis.audio.Title);



Expand Down Expand Up @@ -530,34 +526,34 @@ internal static void PlayPreviousTrack()
PlayTrack();

}
public static ExtendedAudio PlayingTrack = null;

private async static Task PlayTrack(long? v = null)
{


if (v != null) iVKGetAudio.currentTrack = (long)v;

iVKGetAudio.ChangePlayAudio();




var mediaSource = Windows.Media.Core.MediaSource.CreateFromUri(new Uri(_TrackDataThis.Url.ToString()));
var mediaSource = Windows.Media.Core.MediaSource.CreateFromUri(new Uri(_TrackDataThis.audio.Url.ToString()));
var mediaPlaybackItem = new Windows.Media.Playback.MediaPlaybackItem(mediaSource);




MediaItemDisplayProperties props = mediaPlaybackItem.GetDisplayProperties();
props.Type = Windows.Media.MediaPlaybackType.Music;
props.MusicProperties.Title = _TrackDataThis.Title;
props.MusicProperties.AlbumArtist = _TrackDataThis.Artist;
props.MusicProperties.Title = _TrackDataThis.audio.Title;
props.MusicProperties.AlbumArtist = _TrackDataThis.audio.Artist;


if (_TrackDataThis.Album != null)
if (_TrackDataThis.audio.Album != null)
{
RandomAccessStreamReference imageStreamRef = RandomAccessStreamReference.CreateFromUri(new Uri(
_TrackDataThis.Album.Thumb.Photo600 ??
_TrackDataThis.Album.Thumb.Photo270 ??
_TrackDataThis.Album.Thumb.Photo300
_TrackDataThis.audio.Album.Thumb.Photo600 ??
_TrackDataThis.audio.Album.Thumb.Photo270 ??
_TrackDataThis.audio.Album.Thumb.Photo300
));

props.Thumbnail = imageStreamRef;
Expand Down
14 changes: 7 additions & 7 deletions VK UI3/Controls/Blocks/ArtistBannerBlockControl.xaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<UserControl

Margin="0,8,0,0"
x:Class="VK_UI3.Controls.Blocks.ArtistBannerBlockControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Expand All @@ -14,11 +15,11 @@
x:Name="ArtistBanner">


<Image Height="450" HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="ArtistBannerImage" Stretch="UniformToFill">

</Image>
<Grid MaxHeight="450" Height="450">
<Image Height="{Binding ElementName=ArtistBannerImage, Path=Width}" HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="ArtistBannerImage" Stretch="UniformToFill">
</Image>
</Grid>

<Rectangle
Height="450"
Margin="0,0,-15,0"
Expand All @@ -43,9 +44,8 @@
FontFamily="{StaticResource VKSansBold}"
FontSize="50"
FontWeight="Bold"

Text="Artist text" />
<Grid x:Name="ActionsGrid" />
<Grid x:Name="ActionsGrid" HorizontalAlignment="Left" />
</StackPanel>
</Grid>
</UserControl>
18 changes: 9 additions & 9 deletions VK UI3/Controls/TrackControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@
<MenuFlyoutSubItem x:Name="GoArtist" Text="Перейти к исполнителю" Icon="ContactInfo">

</MenuFlyoutSubItem>
<MenuFlyoutItem Text="Перейти в альбом" Click="GoToAlbum">
<MenuFlyoutItem.Icon>
<FontIcon Glyph="&#xE93C;" ></FontIcon>
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>

<MenuFlyoutItem Text="Добавить в плейлист" Click="AddToPlaylist_Click" Icon="Add" />
<MenuFlyoutItem x:Name="disText" Text="Не нравится" Click="DislikeClick">
<MenuFlyoutItem.Icon>

<PathIcon Data="{x:Bind IconData,Mode=OneWay}"/>

<PathIcon Data="{x:Bind IconData, Mode=OneWay}"/>
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
<MenuFlyoutItem Text="Пропускать треки исполнителя" Click="AddArtistIgnore_Click" Icon="BlockContact" />
Expand Down Expand Up @@ -130,9 +134,7 @@

Text="Title"
TextTrimming="CharacterEllipsis">
<ToolTipService.ToolTip>
<ToolTip Content="Перейти к альбому" />
</ToolTipService.ToolTip>

</TextBlock>

<TextBlock
Expand All @@ -155,9 +157,7 @@
Text="Artist"
TextWrapping="NoWrap"
TextTrimming="CharacterEllipsis">
<ToolTipService.ToolTip>
<ToolTip Content="Перейти к исполнителю" />
</ToolTipService.ToolTip>

</TextBlock>
</Grid>

Expand Down
50 changes: 44 additions & 6 deletions VK UI3/Controls/TrackControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
using MusicX.Shared.Player;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using VK_UI3.Controllers;
using VK_UI3.Converters;
Expand All @@ -36,7 +38,7 @@ namespace VK_UI3.Controls
{


public sealed partial class TrackControl : UserControl
public sealed partial class TrackControl : UserControl, INotifyPropertyChanged
{

public TrackControl()
Expand Down Expand Up @@ -88,7 +90,6 @@ private void TrackControl_DataContextChanged(FrameworkElement sender, DataContex

if (track.Album != null && track.Album.Thumb != null)
{

photouri = track.Album.Thumb.Photo270 ??
track.Album.Thumb.Photo300 ??
track.Album.Thumb.Photo600 ??
Expand Down Expand Up @@ -211,7 +212,32 @@ private void SetIconDislike()

}

public string IconData = "m12.4829 18.2961c-.7988.8372-2.0916.3869-2.4309-.5904-.27995-.8063-.6436-1.7718-.99794-2.4827-1.05964-2.1259-1.67823-3.3355-3.38432-4.849-.22637-.2008-.51811-.3626-.84069-.49013-1.12914-.44632-2.19096-1.61609-1.91324-3.0047l.35304-1.76517c.1857-.92855.88009-1.67247 1.79366-1.92162l5.59969-1.52721c2.5456-.694232 5.1395.94051 5.6115 3.53646l.6839 3.7617c.3348 1.84147-1.0799 3.53667-2.9516 3.53667h-.8835l.0103.0522c.0801.4082.1765.9703.241 1.5829.0642.6103.0983 1.2844.048 1.9126-.0493.6163-.1839 1.2491-.5042 1.7296-.1095.1643-.2721.3484-.4347.5188z";
public string _iconData = "m12.4829 18.2961c-.7988.8372-2.0916.3869-2.4309-.5904-.27995-.8063-.6436-1.7718-.99794-2.4827-1.05964-2.1259-1.67823-3.3355-3.38432-4.849-.22637-.2008-.51811-.3626-.84069-.49013-1.12914-.44632-2.19096-1.61609-1.91324-3.0047l.35304-1.76517c.1857-.92855.88009-1.67247 1.79366-1.92162l5.59969-1.52721c2.5456-.694232 5.1395.94051 5.6115 3.53646l.6839 3.7617c.3348 1.84147-1.0799 3.53667-2.9516 3.53667h-.8835l.0103.0522c.0801.4082.1765.9703.241 1.5829.0642.6103.0983 1.2844.048 1.9126-.0493.6163-.1839 1.2491-.5042 1.7296-.1095.1643-.2721.3484-.4347.5188z";

public string IconData
{
get { return _iconData; }
set
{
if (_iconData != value)
{
_iconData = value;
OnPropertyChanged(nameof(IconData));
}
}
}

protected void OnPropertyChanged(string propertyName)
{
this.DispatcherQueue.TryEnqueue(async () =>
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
});
}

public event PropertyChangedEventHandler PropertyChanged;




private void TrackControl_Loading(FrameworkElement sender, object args)
Expand Down Expand Up @@ -329,12 +355,13 @@ private void GoArtist_Click(object sender, RoutedEventArgs e)

public void Download_Click(object sender, RoutedEventArgs e)
{
// Ваш код здесь

}

public void AddToQueue_Click(object sender, RoutedEventArgs e)
{
// Ваш код здесь


}

public void CopyLink(object sender, RoutedEventArgs e) {
Expand All @@ -348,7 +375,7 @@ public void CopyLink(object sender, RoutedEventArgs e) {

public void AddToPlaylist_Click(object sender, RoutedEventArgs e)
{
// Ваш код здесь

}

public void AddRemove_Click(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -410,6 +437,9 @@ private void UCcontrol_PointerPressed(object sender, PointerRoutedEventArgs e)


bool waitDisliked = false;



private void DislikeClick(object sender, RoutedEventArgs e)
{
if (waitDisliked) return;
Expand Down Expand Up @@ -439,6 +469,14 @@ private void DislikeClick(object sender, RoutedEventArgs e)
waitDisliked = false;
});
}

private void GoToAlbum(object sender, RoutedEventArgs e)
{
MainView.OpenPlayList(
dataTrack.audio.Album.Id,
dataTrack.audio.Album.OwnerId,
dataTrack.audio.Album.AccessKey);
}
}
}

17 changes: 15 additions & 2 deletions VK UI3/Helpers/ExtendedAudio.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using MusicX.Core.Models;
using System.ComponentModel;
using VK_UI3.Controllers;
using VK_UI3.VKs.IVK;


Expand All @@ -22,8 +23,20 @@ public bool PlayThis
{
get
{
if (NumberInList == null) return false;
return (NumberInList == iVKGetAudio.currentTrack);

//if (NumberInList == null) return false;
// return (NumberInList == iVKGetAudio.currentTrack);
if (AudioPlayer._TrackDataThis == null) return false;

if (AudioPlayer._TrackDataThis.audio.AccessKey == this.audio.AccessKey)
{
return true;
}
else
return false;

// if (AudioPlayer._TrackDataThis.audio.o)

}
}

Expand Down
1 change: 1 addition & 0 deletions VK UI3/Resource/icons.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
</x:String>



</ResourceDictionary>
4 changes: 2 additions & 2 deletions VK UI3/VKs/VK.cs
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ public static async Task<bool> AddDislike(long Id, long OwnerId)
{
var parameters = new VkParameters
{
{ "audio_ids", $"{Id}_{OwnerId}" }
{ "audio_ids", $"{OwnerId}_{Id}" }
};

var response = await api.CallAsync("audio.addDislike", parameters);
Expand Down Expand Up @@ -836,7 +836,7 @@ public static async Task<bool> RemoveDislike(long Id, long OwnerId)
{
var parameters = new VkParameters
{
{ "audio_ids", $"{Id}_{OwnerId}" }
{ "audio_ids", $"{OwnerId}_{Id}" }
};

var response = await api.CallAsync("audio.removeDislike", parameters);
Expand Down
4 changes: 0 additions & 4 deletions VK UI3/Views/MainView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@
</NavigationViewItem>

<NavigationViewItemSeparator/>




<NavigationViewItemHeader Content="Аккаунты"/>
<NavigationViewItemSeparator/>
<NavigationViewItem Padding="-10,0,-20,0" SelectsOnInvoked="False" >
Expand Down
Loading

0 comments on commit 686625b

Please sign in to comment.