Beispiel #1
0
        /// <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();
 }
Beispiel #4
0
        private void UpdateAutoRating(string file)
        {
            string playCountString = _mbApiInterface.Library_GetFileProperty(file, FilePropertyType.PlayCount);
            string skipCountString = _mbApiInterface.Library_GetFileProperty(file, FilePropertyType.SkipCount);

            int playCount = 0;
            int skipCount = 0;

            if (playCountString.Length > 0)
            {
                playCount = int.Parse(playCountString);
            }

            if (skipCountString.Length > 0)
            {
                skipCount = int.Parse(skipCountString);
            }

            int playDelta = playCount - skipCount;
            int newRating = -1;

            if (playDelta < -5)
            {
                newRating = 1;
            }
            else if (playDelta < -1)
            {
                newRating = 2;
            }
            else if (playDelta < 2)
            {
                newRating = 3;
            }
            else if (playDelta < 6)
            {
                newRating = 4;
            }
            else
            {
                newRating = 5;
            }

            _mbApiInterface.Library_SetFileTag(file, MetaDataType.Rating, newRating.ToString());
            _mbApiInterface.Library_CommitTagsToFile(file);
        }
Beispiel #5
0
        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;
            }
        }