Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MaKrotos committed May 7, 2024
1 parent c4426f3 commit 81678b2
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 288 deletions.
6 changes: 4 additions & 2 deletions VK UI3/Controllers/AudioPlayer.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -584,10 +584,12 @@ private async static Task PlayTrack(long? v = null)
mediaPlayer.Source = mediaPlaybackItem;
mediaPlayer.Play();

iVKGetAudio.ChangePlayAudio();

iVKGetAudio.ChangePlayAudio(trackdata);
AudioPlayedChangeEvent.Invoke(trackdata, EventArgs.Empty);
}

public static event EventHandler AudioPlayedChangeEvent;



private void PreviousBTN_Tapped(object sender, TappedRoutedEventArgs e)
Expand Down
4 changes: 0 additions & 4 deletions VK UI3/VK UI3.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
<None Remove="Views\Settings\SettingsPage.xaml" />
<None Remove="Views\Share\ConversationsList.xaml" />
<None Remove="Views\Share\FriendsList.xaml" />
<None Remove="Views\Share\ShareControllers\AttachmentsController.xaml" />
<None Remove="Views\Share\ShareControllers\ConvController.xaml" />
<None Remove="Views\Share\ShareControllers\FriendsList.xaml" />
<None Remove="Views\Share\ShareControllers\UserControllers.xaml" />
Expand Down Expand Up @@ -200,9 +199,6 @@
<Page Update="Views\Share\ShareControllers\FriendsList.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="Views\Share\ShareControllers\AttachmentsController.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Update="Views\Share\ConversationsList.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
Expand Down
5 changes: 3 additions & 2 deletions VK UI3/VKs/IVK/IVKGetAudio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ public ObservableRangeCollection<ExtendedAudio> listAudio
public void PhotoUpdated() { onPhotoUpdated?.RaiseEvent(this, EventArgs.Empty); }


private long? _countTracks { get; set; }
private long? _countTracks { get; set; } = null;

public long? countTracks { get
{
if (_countTracks != -1) return countTracks;
if (_countTracks == null) return null;
if (_countTracks != -1) return _countTracks;
else return listAudio.Count;

}
Expand Down
97 changes: 59 additions & 38 deletions VK UI3/VKs/IVK/MessagesAudio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using TagLib.Ape;
using VK_UI3.Helpers;
using VK_UI3.Views.Share;
using VkNet.Enums.SafetyEnums;
using VkNet.Model;
using VkNet.Model.Attachments;
using VkNet.Model.RequestParams;
Expand All @@ -14,35 +17,43 @@ namespace VK_UI3.VKs.IVK
{
public class MessagesAudio : IVKGetAudio
{
public MessagesAudio(long id, DispatcherQueue dispatcher) : base(id, dispatcher)
public MessagesAudio(MessConv messConv, DispatcherQueue dispatcher) : base(dispatcher)
{
base.id = id.ToString();
base.id = messConv.conversation.Peer.LocalId.ToString();
this.messConv = messConv;
}



public override long? getCount()
{
return api.Audio.GetCountAsync(long.Parse(id)).Result;
return -1;
}

public User user;
MessConv messConv = null;
public override string getName()
{
try
{
List<long> ids = new List<long> { long.Parse(id) };
user = api.Users.GetAsync(ids).Result[0];

var request = new VkParameters
switch (messConv.conversation.Peer.Type.ToString())
{
{"user_ids", string.Join(",", ids)},
{"fields", string.Join(",", "photo_max_orig", "status")}
};

var response = api.Call("users.get", request);
user = User.FromJson(response[0]);

case "chat":
return messConv.conversation.ChatSettings.Title;


break;
case "user":
return messConv.user.FirstName +" "+messConv.user.LastName;
break;
case "group":
return messConv.group.Name;
break;
case "email":

break;
default:
break;
}

return user.FirstName + " " + user.LastName;
}
catch (Exception ex)
{
Expand All @@ -59,43 +70,53 @@ public override List<string> getPhotosList()

public override Uri getPhoto()
{
if (user != null)
switch (messConv.conversation.Peer.Type.ToString())
{
return
user.PhotoMaxOrig;
case "chat":
return messConv.conversation.ChatSettings.Photo.JustGetPhoto;

break;
case "user":
return messConv.user.JustGetPhoto;
break;
case "group":
return messConv.group.JustGetPhoto;
break;
case "email":

break;
default:
break;
}
else
return null;
return null;
}

string nextFrom = null;
public override void GetTracks()
{
if (getLoadedTracks) return;
getLoadedTracks = true;

Task.Run(async () =>
{
int offset = listAudio.Count;
int count = 250;

int count = 200;

if (countTracks > listAudio.Count)
{

VkCollection<Audio> audios;


audios = api.Audio.GetAsync(new AudioGetParams
MessagesGetHistoryAttachmentsParams messagesGetHistoryAttachmentsParams = new MessagesGetHistoryAttachmentsParams()
{
OwnerId = int.Parse(id),
Offset = offset,
Count = count
}).Result;

Count = 200,
MediaType = MediaType.Audio,
PeerId = messConv.conversation.Peer.Id,
StartFrom = nextFrom
};

var attach = (VK.api.Messages.GetHistoryAttachments(messagesGetHistoryAttachmentsParams, out nextFrom));
ManualResetEvent resetEvent = new ManualResetEvent(false);

foreach (var item in audios)
foreach (var item in attach)
{
ExtendedAudio extendedAudio = new ExtendedAudio(item, this);
ExtendedAudio extendedAudio = new ExtendedAudio(item.Attachment.Instance as Audio, this);

DispatcherQueue.TryEnqueue(() =>
{
Expand All @@ -111,7 +132,7 @@ public override void GetTracks()


getLoadedTracks = false;
}

NotifyOnListUpdate();
});
}
Expand Down
2 changes: 1 addition & 1 deletion VK UI3/VKs/IVK/MixAudio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public MixAudio(string mix_id, DispatcherQueue dispatcher) : base(dispatcher)
{
this.mix_id = mix_id;
//Íó íèêòî æ íå áóäåò ñëóøàòü ñòîëüêî, äà?
this.countTracks = 10000000000000;
this.countTracks = -1;
waitCreate = true;
Task.Run(async () =>
{
Expand Down
2 changes: 0 additions & 2 deletions VK UI3/Views/LoginWindow/Password.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public partial class Password : Page
public int CodeLength { get; set; }
public string? Info { get; set; }



public string FirstName { get; set; } = "Незнакомец";
public string Photo200 { get; set; } = "null";
public string Phone { get; set; } = "***********";
Expand Down
3 changes: 2 additions & 1 deletion VK UI3/Views/SectionView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ public enum SectionType
MyListAudio,
PlayList,
UserPlayListList,
UserSection
UserSection,
MessConv
}

protected override void OnNavigatedTo(NavigationEventArgs e)
Expand Down
30 changes: 0 additions & 30 deletions VK UI3/Views/Share/ChatList.xaml

This file was deleted.

Loading

0 comments on commit 81678b2

Please sign in to comment.