Archived
1
0
This repository has been archived on 2026-04-22. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
FoxTube/FoxTube/Controls/PlaylistCard.xaml.cs
T
2018-07-27 17:07:51 +03:00

72 lines
2.3 KiB
C#

using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
namespace FoxTube.Controls
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class PlaylistCard : Page
{
Playlist item;
string playlistId;
public PlaylistCard(string id)
{
this.InitializeComponent();
Initialize(id);
}
public async void Initialize(string id)
{
PlaylistsResource.ListRequest request = SecretsVault.NoAuthService.Playlists.List("snippet,contentDetails");
request.Id = id;
PlaylistListResponse response = await request.ExecuteAsync();
item = response.Items[0];
playlistId = id;
title.Text = item.Snippet.Title;
channelName.Text = item.Snippet.ChannelTitle;
counter.Text = item.ContentDetails.ItemCount.ToString();
date.Text = item.Snippet.PublishedAt.ToString();
ChannelsResource.ListRequest r = SecretsVault.NoAuthService.Channels.List("snippet");
r.Id = item.Snippet.ChannelId;
try
{
thumbnail.Source = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url));
avatar.ProfilePicture = new BitmapImage(new Uri((await r.ExecuteAsync()).Items[0].Snippet.Thumbnails.Medium.Url));
} catch { }
}
private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
{
Height = e.NewSize.Width * 0.75;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Methods.MainPage.GoToPlaylist(item.Id);
}
}
}