/// <summary> /// プレイリストを取得する /// </summary> /// <returns></returns> public async Task GetPlaylist() { // Playlistをクリアする PlaylistViewModels.Clear(); var factory = new YoutubeServiceFactory(); var service = await factory.Create(); var newPlaylist = service.Playlists.List("snippet"); var newPlaylistItem = service.PlaylistItems.List("snippet"); // 100件まで編集可能とする newPlaylistItem.MaxResults = 100; // チャンネルIDを指定することでも取得可能 // newPlaylist.ChannelId = "UCpkkP5J-16g3zgfuIihCTrA"; newPlaylist.Mine = true; var list = await newPlaylist.ExecuteAsync(); foreach (var playlist in list.Items) { var playlistVm = new PlaylistViewModel(playlist, this); PlaylistViewModels.Add(playlistVm); newPlaylistItem.PlaylistId = playlist.Id; var item = await newPlaylistItem.ExecuteAsync(); foreach (var playlistItem in item.Items) { playlistVm.PlaylistItemViewModels.Add(new PlaylistItemViewModel(playlistItem, playlistVm)); } } }
/// <summary> /// コンストラクタ /// </summary> /// <param name="playlistItem">プレイリストに所属する要素</param> public PlaylistItemViewModel(PlaylistItem playlistItem, PlaylistViewModel playlistViewModel) { PlaylistItem = playlistItem; PlaylistViewModel = playlistViewModel; Image = new ReactivePropertySlim <Avalonia.Media.Imaging.Bitmap>().AddTo(m_Disposables); var client = new WebClientService(); client.DownloadImage(PlaylistItem.Snippet.Thumbnails.Default__.Url, Image); }