public void SendRatingUpdate(string artist, string album, string song, SongRating oldRating, SongRating newRating) { SendRatingUpdate(new QuerySong() { Artist = artist, Album = album, Title = song }, oldRating, newRating); }
public void Rate(SongRating rating) { if (Rating != rating) { try { Station.TransformIfShared(); if (rating == SongRating.none) { _pandora.DeleteFeedback(FeedbackID); } else { _pandora.AddFeedback(Station.IdToken, TrackToken, rating); } Rating = rating; _pandora.CallFeedbackUpdateEvent(this, true); } catch (Exception ex) { Log.O(ex.ToString()); _pandora.CallFeedbackUpdateEvent(this, false); } } }
public void SendRatingUpdate(QuerySong song, SongRating oldRating, SongRating newRating) { foreach (var obj in _pcqList) { obj.RatingUpdateReceiver(song, oldRating, newRating); } }
private void FillLayout() { SongMeta songMeta = sceneData.SongMeta; string titleText = (String.IsNullOrEmpty(songMeta.Title)) ? "" : songMeta.Title; string artistText = (String.IsNullOrEmpty(songMeta.Artist)) ? "" : " - " + songMeta.Artist; songLabel.text = titleText + artistText; int i = 0; GameObject selectedLayout = GetSelectedLayout(); foreach (PlayerProfile playerProfile in sceneData.PlayerProfiles) { sceneData.PlayerProfileToMicProfileMap.TryGetValue(playerProfile, out MicProfile micProfile); PlayerScoreControllerData playerScoreData = sceneData.GetPlayerScores(playerProfile); SongRating songRating = GetSongRating(playerScoreData.TotalScore); Injector childInjector = UniInjectUtils.CreateInjector(injector); childInjector.AddBindingForInstance(playerProfile); childInjector.AddBindingForInstance(micProfile); childInjector.AddBindingForInstance(playerScoreData); childInjector.AddBindingForInstance(songRating); childInjector.AddBinding(new Binding("playerProfileIndex", new ExistingInstanceProvider <int>(i))); SingingResultsPlayerUiController[] uiControllers = selectedLayout.GetComponentsInChildren <SingingResultsPlayerUiController>(); if (i < uiControllers.Length) { childInjector.InjectAllComponentsInChildren(uiControllers[i]); } i++; } }
public async Task <IActionResult> PutSongRating([FromRoute] int id, [FromBody] SongRating songRating) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != songRating.SongRatingId) { return(BadRequest()); } _context.Entry(songRating).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SongRatingExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void RatingUpdateReceiver(QuerySong song, SongRating oldRating, SongRating newRating) { if (!IsEnabled || !_scrobbler.BaseScrobbler.HasSession) { return; } try { Log.O("LastFM, Rating: {0} - {1} - {2}", song.Artist, song.Title, newRating.ToString()); Track track = null; //Get corrected track if there is one //Without getting the corrected track, //ratings will not work if there were corrections. if (song.Meta == null) { track = QuerySongToTrack(song); } else { track = (Track)song.Meta; } switch (newRating) { case SongRating.love: _scrobbler.UnBan(track); _scrobbler.Love(track); break; case SongRating.ban: _scrobbler.UnLove(track); _scrobbler.Ban(track); break; case SongRating.none: if (oldRating == SongRating.love) { _scrobbler.UnLove(track); } else if (oldRating == SongRating.ban) { _scrobbler.UnBan(track); } break; } if (_scrobbler.QueuedCount > 0) { ProcessScrobbles(); } } catch (Exception ex) { Log.O("Last.FM Error!: " + ex.ToString()); } }
private void SetTotalScore(double totalScore) { SongRating songRating = GetSongRating(totalScore); GetComponentInChildren <SongRatingText>().SetSongRating(songRating); GetComponentInChildren <SongRatingImage>().SetSongRating(songRating); GetComponentInChildren <SingingResultsTotalScoreText>().TargetValue = totalScore; GetComponentInChildren <SingingResultsScoreBar>().TargetValue = totalScore; }
public static SongRating Toggle(string absoluteTjaPath, SongRating ratingToggled) { var rating = GetRating(absoluteTjaPath); var newRating = rating == ratingToggled ? SongRating.Unset : ratingToggled; SetRating(absoluteTjaPath, newRating); return(newRating); }
public void SetSongRating(SongRating rating) { SongRatingImageHolder[] holders = FindObjectsOfType <SongRatingImageHolder>(); SongRatingImageHolder holder = holders.Where(it => it.songRatingEnumValue == rating.EnumValue).FirstOrDefault(); if (holder != null) { image.sprite = holder.sprite; } }
public async Task <IActionResult> PostSongRating([FromBody] SongRating songRating) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.SongRating.Add(songRating); await _context.SaveChangesAsync(); return(CreatedAtAction("GetSongRating", new { id = songRating.SongRatingId }, songRating)); }
private void RateSong(Song song, SongRating rating) { if (_isRating) { return; } _isRating = true; SongRating oldRating = song.Rating; song.Rate(rating); _cqman.SendRatingUpdate(song.Artist, song.Album, song.SongTitle, oldRating, rating); _isRating = false; }
public void AddFeedback(string stationToken, string trackToken, SongRating rating) { Log.O("AddFeedback"); bool rate = (rating == SongRating.love) ? true : false; JObject req = new JObject(); req["stationToken"] = stationToken; req["trackToken"] = trackToken; req["isPositive"] = rate; CallRPC("station.addFeedback", req); }
private static int ToComparable(SongRating rating, bool group1IncludesUnset, int group1Min, int group1Max) { if (rating == SongRating.Unset) { return(group1IncludesUnset ? 1 : 2); } var intRating = (int)rating; if (group1Min <= intRating && intRating <= group1Max) { return(1); } return(2); }
public bool RateASong(RateCreate model) { SongRating addRate = new SongRating(); addRate.SongId = model.SongId; addRate.SongRate = model.MyRating; using (var context = new ApplicationDbContext()) { context.SongRatings.Add(addRate); context.SaveChanges(); SongServices myRate = new SongServices(); myRate.AverageRating(model.SongId); return(context.SaveChanges() == 0); }; }
private static void SetRatingImpl(string absoluteTjaPath, SongRating rating) { var absoluteRatingPath = GetAbsoluteRatingPath(absoluteTjaPath); File.Delete(absoluteRatingPath); if (rating == SongRating.Unset) { return; } var lines = new[] { ((int)rating).ToString(), DateTimeOffset.UtcNow.ToString("O") }; File.WriteAllLines(absoluteRatingPath, lines, Encoding.UTF8); }
public bool CreateSongRating(SongRatingCreate model) { // format the new SongRating record var entity = new SongRating() { OwnerId = _userId, SongId = model.SongId, SongIndividualRating = model.SongIndividualRating, Song = model.Song }; // Add the new SongRating to the table using (var ctx = new ApplicationDbContext()) { ctx.SongRatings.Add(entity); bool addedSongRating = ctx.SaveChanges() == 1; if (!addedSongRating) { return(false); } } // Update the Song record using (var ctx = new ApplicationDbContext()) { // retrieve the SongRating record we just posted so we can follow the foreign key to the Song record var newSongRating = ctx .SongRatings .Single(e => e.SongRatingId == entity.SongRatingId && e.OwnerId == _userId); // Update the fields in the Song record at the other end of the foreign key newSongRating.Song.CulumativeRating += model.SongIndividualRating; newSongRating.Song.NumberOfRatings += 1; newSongRating.Song.Rating = newSongRating.Song.CulumativeRating / newSongRating.Song.NumberOfRatings; return(ctx.SaveChanges() == 1); } } // CreateSongRating
public void Rate(SongRating rating) { if (Rating != rating) { try { Station.TransformIfShared(); if (rating == SongRating.none) _pandora.DeleteFeedback(FeedbackID); else _pandora.AddFeedback(Station.IdToken, TrackToken, rating); Rating = rating; _pandora.CallFeedbackUpdateEvent(this, true); } catch (Exception ex) { Log.O(ex.ToString()); _pandora.CallFeedbackUpdateEvent(this, false); } } }
private static void SetRating(string absoluteTjaPath, SongRating rating) { RatingsByAbsoluteTjaPath[absoluteTjaPath] = rating; SetRatingImpl(absoluteTjaPath, rating); }
private void RateSong(Song song, SongRating rating) { if (_isRating) return; _isRating = true; SongRating oldRating = song.Rating; song.Rate(rating); _cqman.SendRatingUpdate(song.Artist, song.Album, song.SongTitle, oldRating, rating); _isRating = false; }
public void SetSongRating(SongRating songRating) { text.text = songRating.Text; }
public void RatingUpdateReceiver(QuerySong song, SongRating oldRating, SongRating newRating) { if (!IsEnabled || !_scrobbler.BaseScrobbler.HasSession) return; try { Log.O("LastFM, Rating: {0} - {1} - {2}", song.Artist, song.Title, newRating.ToString()); Track track = null; //Get corrected track if there is one //Without getting the corrected track, //ratings will not work if there were corrections. if (song.Meta == null) { track = QuerySongToTrack(song); } else track = (Track)song.Meta; switch (newRating) { case SongRating.love: _scrobbler.UnBan(track); _scrobbler.Love(track); break; case SongRating.ban: _scrobbler.UnLove(track); _scrobbler.Ban(track); break; case SongRating.none: if(oldRating == SongRating.love) _scrobbler.UnLove(track); else if(oldRating == SongRating.ban) _scrobbler.UnBan(track); break; } if (_scrobbler.QueuedCount > 0) ProcessScrobbles(); } catch (Exception ex) { Log.O("Last.FM Error!: " + ex.ToString()); } }
public void RatingUpdateReceiver(QuerySong song, SongRating oldRating, SongRating newRating) { }
private static int ToComparableByIndividualRatingsDescending(SongRating songRating) { return(-(int)songRating); }