public bool DeepEquals(DestinyActivityDefinition?other) { return(other is not null && (DisplayProperties is not null ? DisplayProperties.DeepEquals(other.DisplayProperties) : other.DisplayProperties is null) && (OriginalDisplayProperties is not null ? OriginalDisplayProperties.DeepEquals(other.OriginalDisplayProperties) : other.OriginalDisplayProperties is null) && (SelectionScreenDisplayProperties is not null ? SelectionScreenDisplayProperties.DeepEquals(other.SelectionScreenDisplayProperties) : other.SelectionScreenDisplayProperties is null) && ReleaseIcon == other.ReleaseIcon && ReleaseTime == other.ReleaseTime && ActivityLightLevel == other.ActivityLightLevel && DestinationHash == other.DestinationHash && PlaceHash == other.PlaceHash && ActivityTypeHash == other.ActivityTypeHash && Tier == other.Tier && PgcrImage == other.PgcrImage && Rewards.DeepEqualsList(other.Rewards) && Modifiers.DeepEqualsList(other.Modifiers) && IsPlaylist == other.IsPlaylist && Challenges.DeepEqualsList(other.Challenges) && OptionalUnlockStrings.DeepEqualsList(other.OptionalUnlockStrings) && PlaylistItems.DeepEqualsList(other.PlaylistItems) && ActivityGraphList.DeepEqualsList(other.ActivityGraphList) && (Matchmaking is not null ? Matchmaking.DeepEquals(other.Matchmaking) : other.Matchmaking is null) && (GuidedGame is not null ? GuidedGame.DeepEquals(other.GuidedGame) : other.GuidedGame is null) && DirectActivityModeHash == other.DirectActivityModeHash && DirectActivityModeType == other.DirectActivityModeType && Loadouts.DeepEqualsList(other.Loadouts) && ActivityModeHashes.DeepEqualsListNaive(other.ActivityModeHashes) && ActivityModeTypes.DeepEqualsListNaive(other.ActivityModeTypes) && IsPvP == other.IsPvP && InsertionPoints.DeepEqualsList(other.InsertionPoints) && ActivityLocationMappings.DeepEqualsList(other.ActivityLocationMappings) && Hash == other.Hash && Index == other.Index && Redacted == other.Redacted); }
/// <summary> /// Add a list of songs to the playlist /// </summary> /// <param name="playlist"></param> /// <param name="songs"></param> public void AddSongs(IEnumerable <Song> songs) { List <SongPlaylistItem> songPlaylistItems = new(); // For each song create a PlayListItem and add to the PlayList foreach (Song song in songs) { song.Artist = Artists.GetArtistById(ArtistAlbums.GetArtistAlbumById(song.ArtistAlbumId).ArtistId); SongPlaylistItem itemToAdd = new() { Artist = song.Artist, PlaylistId = Id, Song = song, SongId = song.Id, Index = PlaylistItems.Count }; songPlaylistItems.Add(itemToAdd); PlaylistItems.Add(itemToAdd); } // No need to wait for this DbAccess.InsertAllAsync(songPlaylistItems); }
public void StartPlayback(object e) { var pressedItem = (Client.Common.Models.PlaylistItem)(((ItemClickEventArgs)e).ClickedItem); var pressedItemIndex = PlaylistItems.IndexOf(pressedItem); EventAggregator.Publish(new PlayItemAtIndexMessage(pressedItemIndex)); }
public bool IsAlreadyInPlaylist(PlaylistItemType pType, int id) { string[] items = PlaylistItems.Split('|'); foreach (string pitem in items) { string[] parms = pitem.Split(';'); if (parms.Length != 2) { continue; } int objType; int objID; if (!int.TryParse(parms[0], out objType)) { continue; } if (!int.TryParse(parms[1], out objID)) { continue; } if (objType == (int)pType && objID == id) { return(true); } } return(false); }
public async Task <List <IData> > FindAll(string regex) { var searchResults = new List <IData>(); var searchTerm = new Regex(regex, RegexOptions.IgnoreCase | RegexOptions.Compiled); searchResults.AddRange( (await Videos .ToListAsync()) .Where(x => searchTerm.IsMatch(x.Title)) ); searchResults.AddRange( (await Playlists .ToListAsync()) .Where(x => searchTerm.IsMatch(x.Title)) ); searchResults.AddRange( (await PlaylistItems .ToListAsync()) .Where(x => searchTerm.IsMatch(x.Title)) ); return(searchResults); }
/// <inheritdoc/> public async Task MovePlaylistItems(IEnumerable <string> ids, IEnumerable <ResourceId> resourcesIds, string playlistId) { foreach (var id in resourcesIds) { try { AddPlaylistItems(id, playlistId); } catch { // エラーが発生した場合は何もしない } } foreach (var id in ids) { try { await m_YouTubeService !.PlaylistItems.Delete(id).ExecuteAsync(); } catch { // エラーが発生した場合は何もしない } } }
/// <inheritdoc/> public async Task <IEnumerable <Models.PlaylistItem> > GetPlaylistItems(string id) { var playlistItems = m_YouTubeService !.PlaylistItems.List("snippet"); // 100件まで編集可能とする playlistItems.MaxResults = 100; playlistItems.PlaylistId = id; var items = await playlistItems.ExecuteAsync(); var resultPlaylistItems = new List <Models.PlaylistItem>(); foreach (var playlistItem in items.Items) { try { if (playlistItem.Snippet.Thumbnails.Default__ == null) { resultPlaylistItems.Add(new Models.PlaylistItem(playlistItem.Id, playlistItem.Snippet.ResourceId, playlistItem.Snippet.Title, playlistItem.Snippet.Description, string.Empty)); } else { resultPlaylistItems.Add(new Models.PlaylistItem(playlistItem.Id, playlistItem.Snippet.ResourceId, playlistItem.Snippet.Title, playlistItem.Snippet.Description, playlistItem.Snippet.Thumbnails.Default__.Url)); } } catch { // エラーが発生した場合は何もしない } } return(resultPlaylistItems); }
/// <summary> /// Insert songs into the playlist at a given index /// </summary> /// <param name="insertIndex">index inside playlistItems</param> /// <param name="songs">songs to be inserted</param> private void InsertSongs(int insertIndex, List <Song> songs) { foreach (Song song in songs) { PlaylistItem playlistItem = new PlaylistItem(song); PlaylistItems.Insert(insertIndex++, playlistItem); } }
/// <summary> /// Adds a song which is performed by a list of singers in karaokeBarMode /// </summary> /// <param name="song">song that should be enqueued</param> /// <param name="singers">singers performing the song</param> public void EnqueueSong(Song song, IEnumerable <Singer> singers) { PlaylistItem playlistItem = new PlaylistItem(song, singers); PlaylistItems.Add(playlistItem); SelectLastPlaylistItemInGrid(); }
public async Task <List <PlaylistItem> > GetPlaylistItems(string playlistId) { // https://developers.google.com/youtube/v3/docs/playlistItems/list var playlistItems = PlaylistItems.List("contentDetails,id,snippet,status"); playlistItems.PlaylistId = playlistId; return(await HandlePagination <PlaylistItem>(playlistItems)); }
/// <summary> /// Adds a number of songs without singers within the simple mode /// </summary> /// <param name="songs">songs that should be enqueued</param> public void EnqueueSongs(List <Song> songs) { foreach (Song song in songs) { PlaylistItem playlistItem = new PlaylistItem(song); PlaylistItems.Add(playlistItem); } SelectLastPlaylistItemInGrid(); }
/// <summary> /// Adds a single song in Simple (without singer) or KaraokeBar (with singer) mode /// </summary> /// <param name="song">song that should be enqueued</param> /// <param name="startPlayingIfEmptyPlaylist"></param> /// <param name="singer">singer or null</param> public void EnqueueSong(Song song, bool startPlayingIfEmptyPlaylist = false, Singer singer = null) { PlaylistItem playlistItem = new PlaylistItem(song, singer); PlaylistItems.Add(playlistItem); if (PlaylistItems.Count == 1 && startPlayingIfEmptyPlaylist) { PlayItem(playlistItem); } }
/// <summary> /// Clear Playlist /// </summary> /// <param name="response">Playlist Response</param> private async void ClearPlaylist(PlaylistResponse response) { var dialog = new ClearPlaylistDialog(response); var result = await dialog.ShowAsync(); if (result == ContentDialogResult.Primary && dialog.ClearPlaylist.Result.IsSuccess) { PlaylistItems.Refresh(); } }
private async Task LoadPlaylistInfoInternal(string playlistid) { PlaylistItems.Clear(); string pagination = null; string firstpagination = null; // Loop through 4 times to load this completely at least // due to YouTube's 50 result restriction // Max playlist restriction = 200 video anyway for (int i = 0; i < 4; i++) { IList <Google.Apis.YouTube.v3.Data.PlaylistItem> collection = null; // Load playlist var videoInfoRequest = YoutubeService.service.PlaylistItems.List("contentDetails,id,status,snippet"); videoInfoRequest.PlaylistId = playlistid; videoInfoRequest.MaxResults = 50; if (pagination != null) { videoInfoRequest.PageToken = pagination; } try { var videoResultResponse = await videoInfoRequest.ExecuteAsync(); // Set new pagination pagination = videoResultResponse.NextPageToken; if (firstpagination == null) { firstpagination = pagination; // no choice, we might load the first at the end again.. there's no pagination information for the first page } else if (firstpagination == pagination) { break; } collection = videoResultResponse.Items; } catch { } // Add it to new collection if (collection != null) { foreach (Google.Apis.YouTube.v3.Data.PlaylistItem item in collection) { // item.Snippet.ur PlaylistItems.Add(item); } } } // Update playlist item count PlaylistItemsCount = _PlaylistItems.Count; }
/// <inheritdoc/> public async Task RemovePlaylistItems(IEnumerable <string> ids) { foreach (var id in ids) { try { await m_YouTubeService !.PlaylistItems.Delete(id).ExecuteAsync(); } catch { // エラーが発生した場合は何もしない } } }
/// <summary> /// Get the PlaylistItems and associated songs for this playlist /// </summary> /// <param name="playlistItems"></param> public void GetContents(IEnumerable <SongPlaylistItem> playlistItems) { // Get all the SongPlaylistItem entries associated with this SongPlaylist and then the Song entries for each of them PlaylistItems.AddRange(playlistItems.Where(item => item.PlaylistId == Id)); foreach (SongPlaylistItem playlistItem in PlaylistItems) { playlistItem.Song = Songs.GetSongById(playlistItem.SongId); playlistItem.Artist = Artists.GetArtistById(ArtistAlbums.GetArtistAlbumById(playlistItem.Song.ArtistAlbumId).ArtistId); playlistItem.Song.Artist = playlistItem.Artist; } PlaylistItems.Sort((a, b) => a.Index.CompareTo(b.Index)); }
public void LoadState(string parameter, Dictionary <string, object> statePageState) { if (!statePageState.ContainsKey(StatePlaylistKey) || PlaylistItems.Any()) { return; } var bytes = Convert.FromBase64String((string)statePageState[StatePlaylistKey]); var memoryStream = new MemoryStream(bytes); var xmlSerializer = new XmlSerializer(typeof(PlaylistItemCollection)); var playlist = (PlaylistItemCollection)xmlSerializer.Deserialize(memoryStream); PlaylistItems.Clear(); PlaylistItems.AddRange(playlist); }
/// <summary> /// Get the PlaylistItems and associated songs for this playlist /// </summary> /// <param name="playlistItems"></param> public void GetContents(IEnumerable <PlaylistItem> playlistItems) { // Get all the AlbumPlaylistItem entries associated with this AlbumPlaylist and then the Album entries for each of them PlaylistItems.AddRange(playlistItems.Where(item => item.PlaylistId == Id)); foreach (AlbumPlaylistItem playlistItem in PlaylistItems) { playlistItem.Album = Albums.GetAlbumById(playlistItem.AlbumId); // Get the contents of this playlist as the SongIndex processing assumes that the Songs are available playlistItem.Album.GetSongs(); } PlaylistItems.Sort((a, b) => a.Index.CompareTo(b.Index)); }
private async void AddPlaylistItems(ResourceId resourceId, string playlistId) { try { // 以下を参考にプレイリストに指定の動画を追加 // https://github.com/youtube/api-samples/blob/master/dotnet/Google.Apis.YouTube.Samples.Playlists/PlaylistUpdates.cs#L94 var playlistItem = new Google.Apis.YouTube.v3.Data.PlaylistItem(); playlistItem.Snippet = new PlaylistItemSnippet(); playlistItem.Snippet.PlaylistId = playlistId; playlistItem.Snippet.ResourceId = resourceId; await m_YouTubeService !.PlaylistItems.Insert(playlistItem, "snippet").ExecuteAsync(); } catch { // エラーが発生した場合は何もしない } }
public async Task <PlaylistItem> AddVideoToPlaylist(string playlistId, string videoId) { var playlistItem = new PlaylistItem { Snippet = new PlaylistItemSnippet { PlaylistId = playlistId, ResourceId = new ResourceId { Kind = "youtube#video", VideoId = videoId } } }; return(await PlaylistItems.Insert(playlistItem, "snippet").ExecuteAsync()); }
public void RemoveEpisode(int animeEpisodeID) { if (string.IsNullOrEmpty(PlaylistItems)) { return; } string[] items = PlaylistItems.Split('|'); PlaylistItems = ""; // create a new list without the moved item foreach (string pitem in items) { string[] parms = pitem.Split(';'); if (parms.Length != 2) { continue; } int objType; int objID; if (!int.TryParse(parms[0], out objType)) { continue; } if (!int.TryParse(parms[1], out objID)) { continue; } if (objType == (int)PlaylistItemType.Episode && objID == animeEpisodeID) { // remove this old item } else { if (PlaylistItems.Length > 0) { PlaylistItems += "|"; } PlaylistItems += $"{objType};{objID}"; } } }
void RefreshItems() { if (Playlist is LocalPlaylist localPlaylist) { var localPlaylistItems = new ObservableCollection<IVideoContent>(localPlaylist.GetPlaylistItems().ToList()); PlaylistItems = localPlaylistItems; // キューと「あとで見る」はHohoemaPlaylistがリスト内容を管理しているが // ローカルプレイリストは内部DBが書き換えられるだけなので // 表示向けの更新をVMで引き受ける必要がある Observable.FromEventPattern<LocalPlaylistItemRemovedEventArgs>( h => localPlaylist.ItemRemoved += h, h => localPlaylist.ItemRemoved -= h ) .Subscribe(e => { var args = e.EventArgs; foreach (var itemId in args.RemovedItems) { var removedItem = PlaylistItems.FirstOrDefault(x => x.Id == itemId); if (removedItem != null) { localPlaylistItems.Remove(removedItem); } } }) .AddTo(_NavigatingCompositeDisposable); _localMylistManager.LocalPlaylists.ObserveRemoveChanged() .Subscribe(removed => { if (Playlist.Id == removed.Id) { _pageManager.ForgetLastPage(); _pageManager.OpenPage(HohoemaPageType.UserMylist); } }) .AddTo(_NavigatingCompositeDisposable); } else if (Playlist is PlaylistObservableCollection collection) { PlaylistItems = collection; } }
/// <summary> /// Categorise the specified selected objects /// </summary> /// <param name="selectedObjects"></param> public GroupedSelection(IEnumerable <object> selectedObjects) { // Save the unprocessed objects. SelectedObjects = selectedObjects; // Group the objects into sets of Song, PlaylistItem, IPlaylist, Artist, ArtistAlbum, Album and Genre (string) items foreach (object selectedObject in selectedObjects) { if (selectedObject is Song song) { Songs.Add(song); } else if (selectedObject is PlaylistItem playlistItem) { PlaylistItems.Add(playlistItem); } else if (selectedObject is Playlist playlist) { Playlists.Add(playlist); } else if (selectedObject is Artist artist) { Artists.Add(artist); } else if (selectedObject is ArtistAlbum artistAlbum) { ArtistAlbums.Add(artistAlbum); } else if (selectedObject is Album album) { Albums.Add(album); } else if (selectedObject is string str) { Genres.Add(str); } } // Determine if there is a parent playlist if (PlaylistItems.Count > 0) { ParentPlaylist = DBTest.Playlists.GetParentPlaylist(PlaylistItems[0]); } }
public MainViewModel() { instance = this; this.Login = new LoginViewModel(); this.LibraryModel = new LibraryViewModel(0); this.LibraryPromoModel = new LibraryPromoViewModel(); this.LibraryDetailModel = new LibraryDetailViewModel(); this.LibraryTypeModel = new LibraryTypeViewModel(1); this.PlaylistItems = new ObservableCollection <PlaylistItem>(); PlaylistItems.Add(new PlaylistItem( new Playlist { Title = "Home", IsDynamic = false })); this.PlaylistViewModel = new PlaylistViewModel(PlaylistItems[0]); // this.Library = this.LibraryModel.Library; // this.LibraryDetail = new LibraryDetailViewModel.LibraryDetail(); this.LoadMenu(); }
private void StartPreviousItem() { var currentIndex = PlaylistItems.IndexOf(SelectedItem); if (currentIndex <= 0) { return; } SelectedItem = PlaylistItems[currentIndex - 1]; if (SelectedItem.IsPlaceHolder.HasValue && SelectedItem.IsPlaceHolder.Value) { MessageBox.Show(AppResources.MessagePlaceholder, string.Empty, MessageBoxButton.OK); StartPreviousItem(); return; } InitiatePlayback(false).ConfigureAwait(false); }
public bool DeepEquals(DestinyActivityDefinition other) { return(other != null && ActivityGraphList.DeepEqualsReadOnlyCollections(other.ActivityGraphList) && ActivityLevel == other.ActivityLevel && ActivityLightLevel == other.ActivityLightLevel && ActivityLocationMappings.DeepEqualsReadOnlyCollections(other.ActivityLocationMappings) && ActivityModes.DeepEqualsReadOnlyCollections(other.ActivityModes) && ActivityModeTypes.DeepEqualsReadOnlySimpleCollection(other.ActivityModeTypes) && ActivityType.DeepEquals(other.ActivityType) && Challenges.DeepEqualsReadOnlyCollections(other.Challenges) && CompletionUnlockHash == other.CompletionUnlockHash && Destination.DeepEquals(other.Destination) && DirectActivityMode.DeepEquals(other.DirectActivityMode) && DirectActivityModeType == other.DirectActivityModeType && DisplayProperties.DeepEquals(other.DisplayProperties) && (GuidedGame != null ? GuidedGame.DeepEquals(other.GuidedGame) : other.GuidedGame == null) && InheritFromFreeRoam == other.InheritFromFreeRoam && InsertionPoints.DeepEqualsReadOnlyCollections(other.InsertionPoints) && IsPlaylist == other.IsPlaylist && IsPvP == other.IsPvP && (Matchmaking != null ? Matchmaking.DeepEquals(other.Matchmaking) : other.Matchmaking == null) && Modifiers.DeepEqualsReadOnlyCollections(other.Modifiers) && OptionalUnlockStrings.DeepEqualsReadOnlyCollections(other.OptionalUnlockStrings) && OriginalDisplayProperties.DeepEquals(other.OriginalDisplayProperties) && PgcrImage == other.PgcrImage && Place.DeepEquals(other.Place) && PlaylistItems.DeepEqualsReadOnlyCollections(other.PlaylistItems) && ReleaseIcon == other.ReleaseIcon && ReleaseTime == other.ReleaseTime && Rewards.DeepEqualsReadOnlyCollections(other.Rewards) && (SelectionScreenDisplayProperties != null ? SelectionScreenDisplayProperties.DeepEquals(other.SelectionScreenDisplayProperties) : other.SelectionScreenDisplayProperties == null) && SuppressOtherRewards == other.SuppressOtherRewards && Tier == other.Tier && Loadouts.DeepEqualsReadOnlyCollections(other.Loadouts) && Blacklisted == other.Blacklisted && Hash == other.Hash && Index == other.Index && Redacted == other.Redacted); }
public async Task <List <VideoData> > GetUncategorizedVideos(List <string> playlistTitles) { var playlists = (await Playlists .Where(x => playlistTitles.Contains(x.Title)) .ToListAsync()) .Select(x => x.Id) .ToList(); var videosOnlyInOnePlaylist = new HashSet <string>( PlaylistItems .AsEnumerable() .GroupBy(x => x.VideoId) .Where(x => x.Count() <= 1) .Select(x => new { VideoId = x.Key, PlaylistId = x.First().PlaylistDataId }) .Where(x => playlists.Any(y => x.PlaylistId == y)) .Select(x => x.VideoId) ); return(await Videos.Where(x => videosOnlyInOnePlaylist.Contains(x.Id)) .OrderBy(x => x.Title) .ToListAsync()); }
/// <summary> /// Add a list of albums to the playlist /// </summary> /// <param name="albums"></param> public void AddAlbums(IEnumerable <Album> albums) { // For each song create an AlbumPlayListItem and add to the PlayList List <AlbumPlaylistItem> albumPlaylistItems = new(); foreach (Album album in albums) { AlbumPlaylistItem itemToAdd = new() { Album = album, PlaylistId = Id, AlbumId = album.Id, Index = PlaylistItems.Count }; PlaylistItems.Add(itemToAdd); albumPlaylistItems.Add(itemToAdd); } // No need to wait for this to complete DbAccess.InsertAllAsync(albumPlaylistItems); }
public string GetYoutubeChannelVideos(string userid, string profileid) { string ret = string.Empty; string strfinaltoken = string.Empty; string channelDetails = string.Empty; Domain.Socioboard.Domain.YoutubeAccount objYoutubeAccount = objYoutubeAccountRepository.getYoutubeAccountDetailsById(profileid, Guid.Parse(userid)); Domain.Socioboard.Domain.YoutubeChannel objYoutubeChannel = objYoutubeChannelRepository.getYoutubeChannelDetailsById(profileid, Guid.Parse(userid)); oAuthTokenYoutube objoAuthTokenYoutube = new oAuthTokenYoutube(); string finaltoken = objoAuthTokenYoutube.GetAccessToken(objYoutubeAccount.Refreshtoken); JObject objArray = JObject.Parse(finaltoken); //foreach (var item in objArray) //{ try { strfinaltoken = objArray["access_token"].ToString(); // break; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } //} PlaylistItems objPlaylistItems = new PlaylistItems(); try { channelDetails = objPlaylistItems.Get_PlaylistItems_List(strfinaltoken, GlobusGooglePlusLib.Authentication.oAuthTokenYoutube.Parts.snippet.ToString(), objYoutubeChannel.Uploadsid); } catch (Exception ex) { } return(channelDetails); }
/// <inheritdoc/> public async Task AddVideosToPlaylistItem(IEnumerable <Models.Video> videos, Models.Playlist playlist) { // 入力の検証 foreach (var video in videos) { try { // 以下を参考にプレイリストに指定の動画を追加 // https://github.com/youtube/api-samples/blob/master/dotnet/Google.Apis.YouTube.Samples.Playlists/PlaylistUpdates.cs#L94 var actualPlaylistItem = new Google.Apis.YouTube.v3.Data.PlaylistItem(); actualPlaylistItem.Snippet = new PlaylistItemSnippet(); actualPlaylistItem.Snippet.PlaylistId = playlist.PlaylistId; actualPlaylistItem.Snippet.ResourceId = new ResourceId(); actualPlaylistItem.Snippet.ResourceId.Kind = "youtube#video"; actualPlaylistItem.Snippet.ResourceId.VideoId = video.VideoId; _ = await m_YouTubeService !.PlaylistItems.Insert(actualPlaylistItem, "snippet").ExecuteAsync(); } catch { // エラーが発生した場合は何もしない } } }