public async Task PlayPlaylist(PlaylistSong playlistSong, GroupInfo groupInfo, string playlistId = "") { LogManager.Shared.LogPlayback(playlistSong); SendEndNotification(ScrobbleManager.PlaybackEndedReason.Skipped); Settings.CurrentPlaybackContext = new PlaybackContext { IsContinuous = false, Type = PlaybackContext.PlaybackType.Playlist, ParentId = playlistSong?.PlaylistId ?? playlistId, }; Pause(); var song = playlistSong == null ? null : Database.Main.GetObject <Song, TempSong>(playlistSong.SongId); var info = groupInfo.Clone(); await Task.WhenAll( NativePlayer.PlaySong(song), Task.Run(async() => { string query = $"select SongId as Id from PlaylistSong {info.FilterString(true)} {info.OrderByString(true)} {info.LimitString()}"; await SetupCurrentPlaylist(query, song?.Id ?? "", info.Params); })); if (song == null) { song = GetSong(CurrentSongIndex); await NativePlayer.PlaySong(song); } await PrepareNextTrack(); }
public HttpResponseMessage AddSong(int id, PlaylistSongDto playlistSongDto) { try { using (var unitOfWork = new UnitOfWork()) { var playlist = unitOfWork.PlaylistRepository.Get(id); var song = unitOfWork.SongRepository.Get(playlistSongDto.Song.Id); var playlistSong = new PlaylistSong { Playlist = playlist, Song = song, Position = playlistSongDto.Position }; unitOfWork.PlaylistSongRepository.Save(playlistSong); unitOfWork.Commit(); playlistSongDto.Id = playlistSong.Id; return(Request.CreateResponse(HttpStatusCode.Created, playlistSongDto)); } } catch (Exception ex) { IocUnityContainer.Instance.Resolve <ILogManager>().DefaultLogger.Error.Write(ex.Message, ex); throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public async Task <Playlist> AddPlaylistSongAsync(PlaylistSong playlistSong) { var playlist = await _dbContext.Playlists .Include(p => p.PlaylistSongs).ThenInclude(ps => ps.Song) .FirstOrDefaultAsync(p => p.Id == playlistSong.PlaylistId); if (playlist == null) { return(null); } var song = await _dbContext.Songs .FirstOrDefaultAsync(s => s.Id == playlistSong.SongId); if (song == null) { return(null); } var newPlaylistSong = new PlaylistSong { Playlist = playlist, Song = song }; var entryResult = await _dbContext.PlaylistSongs.AddAsync(newPlaylistSong); await _dbContext.SaveChangesAsync(); return(entryResult.Entity.Playlist); }
private async void BtnOkClick(object sender, System.EventArgs e) { Playlist playlist = new Playlist { Name = editText.Text.Trim(), UserID = GlobalMemory._user.UserID }; if (GlobalMemory._user.Playlists == null) { if (await APIHelper.PostPlaylist(playlist)) { if (await APIHelper.GetPlaylists()) { Toast.MakeText(this.Activity, "Dodano playlistę", ToastLength.Short).Show(); } else { Toast.MakeText(this.Activity, "Coś poszło nie tak", ToastLength.Short).Show(); } } } else { if ((from p in GlobalMemory._user.Playlists where p.Name.Trim().ToUpper() == editText.Text.Trim().ToUpper() select p).ToList().Count > 0) { Toast.MakeText(this.Activity, "Playlista o podanej nazwie już istnieje", ToastLength.Short).Show(); this.Dismiss(); return; } if (await APIHelper.PostPlaylist(playlist)) { if (await APIHelper.GetPlaylists()) { var p = GlobalMemory._user.Playlists.ToList(); PlaylistSong PS = new PlaylistSong { PlaylistID = p.Last().PlaylistID, SongID = GlobalMemory.actualSong.SongID }; if (await APIHelper.PostSongToPlaylist(PS)) { Toast.MakeText(this.Activity, "Dodano utwór i playlistę", ToastLength.Short).Show(); this.Dismiss(); return; } Toast.MakeText(this.Activity, "Coś poszło nie tak", ToastLength.Short).Show(); } else { Toast.MakeText(this.Activity, "Coś poszło nie tak", ToastLength.Short).Show(); } } else { Toast.MakeText(this.Activity, "Coś poszło nie tak", ToastLength.Short).Show(); } } this.Dismiss(); }
public async Task AddToPlaylistAsync(Playlist playlist, Song song) { var tail = playlist.Songs.LastOrDefault(); // Create the new queue entry var newSong = new PlaylistSong { SongId = song.Id, NextId = 0, PrevId = tail == null ? 0 : tail.Id, Song = song, PlaylistId = playlist.Id }; // Add it to the database await _sqlService.InsertAsync(newSong); if (tail != null) { // Update the next id of the previous tail tail.NextId = newSong.Id; await _sqlService.UpdateItemAsync(tail); } // Add the new queue entry to the collection and map playlist.Songs.Add(newSong); playlist.LookupMap.TryAdd(newSong.Id, newSong); }
/// <summary> /// The reads the playlist file and populates the display list. /// </summary> public void ShowPlaylistCommandAction() { List <string> songs = GetPlaylistSongs(); string sourceDirectory = Path.GetDirectoryName(Playlist); SongsReadFromPlaylist.Clear(); int trackNumber = 1; foreach (var song in songs) { var songPath = Path.Combine(sourceDirectory, song); TagLib.File file = TagLib.File.Create(songPath); PlaylistSong songFile = new PlaylistSong() { TrackNumber = trackNumber }; songFile.Artist = file.Tag.FirstAlbumArtist; songFile.Song = file.Tag.Title; songFile.Album = file.Tag.Album; SongsReadFromPlaylist.Add(songFile); trackNumber++; } OnPropertyChanged(() => SongsReadFromPlaylist); }
public async Task <string> song2playlist(int songId, int playlistId) { var song = _context.Song.Where(item => item.ID == songId).First(); var playlist = _context.PlayList.Where(item => item.Id == playlistId).First(); var userid = _userManager.GetUserId(User); var songpl = new PlaylistSong { IdPlaylist = playlistId, IdSong = songId }; if (song.UserId != userid) { return("Negato"); } if (playlist.UserId != userid) { return("Negato"); } if (_context.PlayListSong.Any(x => x.IdPlaylist == playlistId && x.IdSong == songId)) { return("canzone gia presente nella playlist"); } else { _context.PlayListSong.Add(songpl); _context.SaveChanges(); return("Success"); } }
public async Task PlayTempPlaylist(PlaylistSong playlistSong, GroupInfo groupInfo, string playlistId = "") { SendEndNotification(PlaybackEndedReason.Skipped); Settings.CurrentPlaybackContext = new PlaybackContext { IsContinuous = false, Type = PlaybackContext.PlaybackType.Playlist, ParentId = playlistSong?.PlaylistId ?? playlistId, }; Pause(); var song = playlistSong == null ? null : Database.Main.GetObject <Song, TempSong> (playlistSong.SongId); var info = groupInfo.Clone(); await Task.WhenAll( Player.PlaySong(song), Task.Run(async() => { string query = $"select SongId as Id from TempPlaylistSong {info.FilterString (true)} {info.OrderByString (true)} {info.LimitString ()}"; var queryInfo = info.ConvertSqlFromNamed(query); await SetupCurrentPlaylist(queryInfo.Item1, song?.Id ?? "", queryInfo.Item2); })); if (song == null) { song = GetSong(CurrentSongIndex); await Player.PlaySong(song); } await PrepareNextTrack(); }
public override async Task <bool> DeletePlaylistSong(PlaylistSong song) { try { if (!RequiresAuthentication) { Database.Main.Delete(song); return(true); } var resp = await Api.Delete(path : "playlistItems", queryParameters : new Dictionary <string, string> { { "id", song.Id } }); var success = string.IsNullOrWhiteSpace(resp); if (success) { Database.Main.Delete(song); } return(success); } catch (Exception ex) { LogManager.Shared.Report(ex); } return(false); }
public async Task <IActionResult> PostPlaylistSong([FromBody] PlaylistSong playlistSong) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.PlaylistSong.Add(playlistSong); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (PlaylistSongExists(playlistSong.SongId)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtAction("GetPlaylistSong", new { id = playlistSong.SongId }, playlistSong)); }
public override async Task <bool> MoveSong(PlaylistSong song, string previousId, string nextId, int index) { try { var body = new Google.Apis.Youtube.v3.Data.PlaylistItem { Snippet = new PlaylistItemSnippet { PlaylistId = song.PlaylistId, ResourceId = new ResourceId { Kind = "youtube#video", VideoId = song.SongId, }, Position = index, }, Id = song.Id }; var resp = await Api.Put <Google.Apis.Youtube.v3.Data.PlaylistItem>(body, "playlistItems?part=snippet"); SyncPlaylists(); return(resp.Snippet.Position == index); } catch (Exception ex) { LogManager.Shared.Report(ex); } return(false); }
public async Task <IActionResult> PutPlaylistSong([FromRoute] int id, [FromBody] PlaylistSong playlistSong) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != playlistSong.PlaylistSongId) { return(BadRequest()); } _context.Entry(playlistSong).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PlaylistSongExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IEnumerator GetInfoForSong(Playlist playlist, PlaylistSong song, Action <Song> songCallback) { string url = $"{PluginConfig.beatsaverURL}/api/songs/detail/{song.key}"; if (!string.IsNullOrEmpty(playlist.customDetailUrl)) { url = playlist.customDetailUrl + song.key; } UnityWebRequest www = UnityWebRequest.Get(url); www.timeout = 15; yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Logger.Error($"Unable to connect to {PluginConfig.beatsaverURL}! " + (www.isNetworkError ? $"Network error: {www.error}" : (www.isHttpError ? $"HTTP error: {www.error}" : "Unknown error"))); } else { try { JSONNode node = JSON.Parse(www.downloadHandler.text); songCallback?.Invoke(new Song(node["song"])); } catch (Exception e) { Logger.Exception("Unable to parse response! Exception: " + e); } } }
async void SetValues(PlaylistSong playlistsong) { if (playlistsong == null) { return; } var song = playlistsong.Song; ShowOffline = song?.OfflineCount > 0; SetText(playlistsong.Song); var locaImage = song == null ? null : await song.GetLocalImage(ImageWidth); if (locaImage != null) { ImageView.Image = locaImage; } else { var artUrl = await ArtworkManager.Shared.GetArtwork(song); if (string.IsNullOrWhiteSpace(artUrl)) { ImageView.Image = Images.GetDefaultSongImage(ImageWidth); } else { ImageView.SetImage(NSUrl.FromString(artUrl), Images.GetDefaultSongImage(ImageWidth)); } } }
public async Task AddSongToPlaylist(SongToPlaylistCreateModel model) { PlaylistSong playlistSong = model.To <PlaylistSong>(); await this.context.PlaylistSongs.AddAsync(playlistSong); await this.context.SaveChangesAsync(); }
public PlaylistSongViewModel(PlaylistSong song) : base(song, null) { foreach (PlaylistRecording recording in song.PlaylistRecordings) { Children.Add(new PlaylistRecordingViewModel(recording, this)); } }
public async Task AddSongToPlaylist(PlaylistSong playlistSong) { using (var context = ContextFactory.CreateDbContext(ConnectionString)) { context.PlaylistSongs.Add(playlistSong); await context.SaveChangesAsync(); } }
/// <summary> /// If the provided song exists in history, change the flag to the one provided. Returns true if the song was found. /// </summary> /// <param name="song"></param> /// <param name="flag"></param> /// <returns></returns> public bool TryUpdateFlag(PlaylistSong song, HistoryFlag flag) { if (song == null) { return(false); } return(TryUpdateFlag(song.Hash, flag)); }
public bool TryUpdateDate(PlaylistSong song, DateTime newDate) { if (song == null) { return(false); } return(TryUpdateDate(song.Hash, newDate)); }
public bool AddSongToPlaylist(AddSongToPlaylistRequest playlist) { PlaylistSong play = new PlaylistSong(); play.PlaylistId = playlist.PlaylistId; play.SongId = playlist.SongId; db.PlaylistSong.Add(play); db.SaveChanges(); return(true); }
public void addSong(Song s, Playlist p) { autoId++; PlaylistSong pl = new PlaylistSong(); pl.Id = autoId; pl.PlaylistId = p.Id; pl.SongId = s.Id; this.pls.Add(pl); }
public void TestMethod1() { var playlists = PlaylistManager.DefaultPlaylists; var song1 = new PlaylistSong("63F2998EDBCE2D1AD31917E4F4D4F8D66348105D", "Sun Pluck", "3a9b", "ruckus"); //StackTest(); foreach (var playlist in playlists.Values) { } }
PlaylistSong GetSongData( Song song, Artist exclusiveArtist = null, Recording exclusiveRecording = null) { Database.Playlist currentPlaylist = GetCurrentPlaylist(); string playlistName; if (exclusiveRecording != null) { playlistName = $"{exclusiveRecording.Artist.Name} - {exclusiveRecording.Song.Title}"; } else if (exclusiveArtist != null) { playlistName = $"{exclusiveArtist.Name} - {song.Title}"; } else { List <Artist> artists = new List <Artist>( (from recording in song.Recordings select recording.Artist).Distinct()); if (artists.Count == 1) { playlistName = $"{artists[0].Name} - {song.Title}"; } else { playlistName = $"Various - {song.Title}"; } } PlaylistSong newSong = new PlaylistSong( song: song, title: playlistName) { Playlist = currentPlaylist, Weight = song.Weight }; db.PlaylistSongs.Add(newSong); foreach (PlaylistRecording recording in GetRecordingList( song: song, exclusiveArtist: exclusiveArtist, exclusiveRecording: exclusiveRecording)) { recording.PlaylistSong = newSong; db.PlaylistRecordings.Add(recording); } return(newSong); }
public void LogPlayback(PlaylistSong entry) { try { TrackEvent("Play playlist entry"); } catch (Exception ex) { Report(ex); } }
public void TryAdd_PlaylistSong_NotInitialized() { var historyManager = new HistoryManager(); string hash = "LKSJDFLKJASDLFKJ"; string songName = "TestName"; string songKey = "aaaa"; string mapper = "SomeMapper"; PlaylistSong song = new PlaylistSong(hash, songName, songKey, mapper); Assert.ThrowsException <InvalidOperationException>(() => historyManager.TryAdd(song, 0)); }
public void PreviewBeatmapLevelUpdated(IPreviewBeatmapLevel beatmapLevel) { if (beatmapLevel is PlaylistSong selectedPlaylistSong) { this.selectedPlaylistSong = selectedPlaylistSong; } else { this.selectedPlaylistSong = null; } }
public void AddSongToPlaylist(int songId, int playlistId) { var playlistSongEntity = new PlaylistSong { PlaylistId = playlistId, SongId = songId }; context.PlaylistSong.Add(playlistSongEntity); context.SaveChanges(); }
private void SetPlayerStatusInfo(PlaylistSong song) { _playerStatus.IsPlaying = true; _playerStatus.CurrentPlaylistSong = song; Player.Dispatcher.BeginInvoke( new Action( () => { _playerStatus.Volume = Player.Volume; } )); }
public async Task <bool> MoveSong(PlaylistSong song, string previousId, string nextId, int index) { var playlist = Database.Main.GetObject <Playlist>(song.PlaylistId); var provider = ApiManager.Shared.GetMusicProvider(playlist.ServiceId); var success = await provider.MoveSong(song, previousId, nextId, index); if (success) { provider.SyncDatabase(); } return(success); }
public async Task <bool> Delete(PlaylistSong song) { var playlist = Database.Main.GetObject <Playlist>(song.PlaylistId); var provider = ApiManager.Shared.GetMusicProvider(playlist.ServiceId); var success = await provider.DeletePlaylistSong(song); if (success) { provider.SyncDatabase(); } return(success); }
protected bool Equals(PlaylistSong other) { return Equals(Song, other.Song); }