/// <inheritdoc/> public string SetRating(string rating) { var currentTrack = _api.NowPlaying_GetFileUrl(); var decimalSeparator = Convert.ToChar(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, CultureInfo.CurrentCulture); try { rating = rating.Replace('.', decimalSeparator); if (!float.TryParse(rating, out var fRating)) { fRating = -1; } if ((fRating >= 0 && fRating <= 5) || string.IsNullOrEmpty(rating)) { var value = string.IsNullOrEmpty(rating) ? string.Empty : fRating.ToString(CultureInfo.CurrentCulture); _api.Library_SetFileTag(currentTrack, MetaDataType.Rating, value); _api.Library_CommitTagsToFile(currentTrack); _api.Player_GetShowRatingTrack(); _api.MB_RefreshPanels(); } } catch (Exception) { // Ignored exception? should log } return(_api.Library_GetFileTag(currentTrack, MetaDataType.Rating).Replace(decimalSeparator, '.')); }
public void changeRating(float number) { String url = mbApiInterface_.NowPlaying_GetFileUrl(); mbApiInterface_.Library_SetFileTag(url, MetaDataType.Rating, number.ToString()); mbApiInterface_.Library_CommitTagsToFile(url); mbApiInterface_.MB_RefreshPanels(); }
public void IncrementPlayCount(object sender, EventArgs e) { string[] mySelectedFiles = new string[] { }; mbApiInterface.Library_QueryFilesEx("domain=SelectedFiles", ref mySelectedFiles); foreach (string myfile in mySelectedFiles) { string currentValue = mbApiInterface.Library_GetFileTag(myfile, (MetaDataType)FilePropertyType.PlayCount); int newValue = Int32.Parse(currentValue) + 1; mbApiInterface.Library_SetFileTag(myfile, (MetaDataType)FilePropertyType.PlayCount, newValue.ToString()); mbApiInterface.Library_CommitTagsToFile(myfile); } mbApiInterface.MB_RefreshPanels(); }
public void ParseValues(int currentSong) { configMgr = new ConfigMgr(); Dictionary <int, string> DeserializedDict = configMgr.DeserializeIntoDict(_workingDirectory + @"\DRconfig.xml", new Dictionary <int, string>()); int I = 0; using (var reader = new StreamReader(_fileDirectory + CurrentTitle(currentSong) + ".txt")) { while (!reader.EndOfStream) { var line = reader.ReadLine(); if (line.StartsWith(" I:") | line.StartsWith(" Threshold:") | line.StartsWith(" LRA:") | line.StartsWith(" LRA low:") | line.StartsWith(" LRA high:") | line.StartsWith(" Peak:")) { line = Regex.Replace(line, @"[a-zA-Z /\s/g :]", ""); data[I] = line; I++; } } int i = 0; foreach (var o in DeserializedDict) { string unit = null; //MessageBox.Show("Key: " + o.Key + "\nVal: " + o.Value.ToString()); if (o.Value != "None" && o.Key != 7 && o.Key != 8) { if (o.Key == 2) { unit = " LU"; } else if (o.Key == 6) { unit = " dBFS"; } else { unit = " LUFS"; } string temp; MetaDataType tag; DeserializedDict.TryGetValue(i, out temp); tagsDictionary.TryGetValue(temp, out tag); //MessageBox.Show("Temp: " + temp + "\nTag: " + tag + "\nData: " + data[i]); mbApiInterface.Library_SetFileTag(files[currentSong], tag, data[i] + unit); } i += 1; } mbApiInterface.Library_CommitTagsToFile(files[currentSong]); mbApiInterface.MB_RefreshPanels(); _checkNum += 1; if (_checkNum == _selectedNum) { MessageBox.Show("Tagging Complete!"); } //MessageBox.Show(data[0] + "\n" + data[1] + "\n" + data[2] + "\n" + data[3] + "\n" + data[4] + "\n" + data[5]); return; } }
private void DrawPanel(object sender, PaintEventArgs e) { var bg = panel.BackColor; var text1 = panel.ForeColor; var text2 = text1; var highlight = Color.FromArgb(2021216); e.Graphics.Clear(bg); panel.Cursor = Cursors.Hand; if (_runOnce) { SpotifyWebAuth(); _trackMissing = 1; mbApiInterface.MB_RefreshPanels(); panel.Invalidate(); _runOnce = false; } if (_auth == 1 && _trackMissing != 1) { TextRenderer.DrawText(e.Graphics, _title, largeBold, new Point(5, 10), text1); TextRenderer.DrawText(e.Graphics, _artist, smallRegular, new Point(5, 30), text1); TextRenderer.DrawText(e.Graphics, _album, smallRegular, new Point(5, 50), text1); WebClient webClient = new WebClient(); byte[] data = webClient.DownloadData(_imageURL); System.Drawing.Image image = System.Drawing.Image.FromStream(new MemoryStream(data)); image = new Bitmap(image, new Size(65, 65)); e.Graphics.DrawImage(image, new Point(10, 80)); webClient.Dispose(); if (CheckTrack(_trackID)) { TextRenderer.DrawText(e.Graphics, "Track Saved in Library", smallBold, new Point(80, 85), text1); } else { TextRenderer.DrawText(e.Graphics, "Track Not in Library", smallRegular, new Point(80, 85), text1); } if (CheckAlbum(_albumID)) { TextRenderer.DrawText(e.Graphics, "Album Saved in Library", smallBold, new Point(80, 105), text1); } else { TextRenderer.DrawText(e.Graphics, "Album Not in Library", smallRegular, new Point(80, 105), text1); } if (CheckArtist(_artistID)) { TextRenderer.DrawText(e.Graphics, "Artist Already Followed", smallBold, new Point(80, 125), text1); } else { TextRenderer.DrawText(e.Graphics, "Artist Not Followed", smallRegular, new Point(80, 125), text1); } } else if (_auth == 1 && _trackMissing == 1) { TextRenderer.DrawText(e.Graphics, "No Track Found!", new Font(panel.Font.FontFamily, 12), new Point(5, 70), text1); } else if (_auth == 0) { TextRenderer.DrawText(e.Graphics, "Please Click Here to \nAuthenticate Spotify.", new Font(panel.Font.FontFamily, 14), new Point(4, 50), text1); } }