Пример #1
0
 /// <summary>
 /// Поиск файла в папке
 /// </summary>
 /// <param name="dir"></param>
 /// <param name="pattern"></param>
 /// <param name="recursive"></param>
 public void FindInDir(DirectoryInfo dir, string pattern, bool recursive)
 {
     try
     {
         foreach (FileInfo file in dir.GetFiles(pattern))
         {
             MusicClass s = new MusicClass();
             s.Path = new Uri(file.FullName);
             s.Name = file.Name;
             lbMusic.Items.Add(s.Name);
             fullList.Add(s);
         }
         if (recursive)
         {
             foreach (DirectoryInfo subdir in dir.GetDirectories())
             {
                 FindInDir(subdir, pattern, recursive);
             }
         }
     }
     catch (System.Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Пример #2
0
        public void CreatePL(List <MusicClass> _fullList)
        {
            int num     = 1;
            int _countM = _fullList.Count;

            tmpList.Clear();
            for (int i = 0; i < _countM.ToString().Length; i++)
            {
                num *= 10;
            }
            int qq = 1;

            MusicClass fi, tmpMC;

            do
            {
                tmpMC = new MusicClass();
                int _tmpRnd = rnd.Next(_fullList.Count);
                fi = _fullList[_tmpRnd];

                double q = (double)qq / (double)num;

                string numName = q.ToString().Substring(q.ToString().IndexOf(',') + 1);

                if (numName.Length <= _countM.ToString().Length)
                {
                    int tt = _countM.ToString().Length - numName.Length;

                    for (int i = 0; i < tt; i++)
                    {
                        numName += "0";
                    }
                }

                string name = numName + ".mp3";

                tmpMC.Id   = qq;
                tmpMC.Name = Path.Combine(SavePath, name);
                tmpMC.Path = fi.Path;

                tmpList.Add(tmpMC);

                qq++;
                _fullList.RemoveAt(_tmpRnd);
            } while (_fullList.Count != 0);

            DownloadMusicFiles(tmpList);
        }
Пример #3
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            music frmMusic = new music();

            frmMusic.Owner = this;

            if (frmMusic.ShowDialog() == true)
            {
                foreach (var r in frmMusic.listVk)
                {
                    MusicClass mc = new MusicClass();
                    mc = r;
                    vkList.Add(mc);
                    lbMusic.Items.Add(mc.Name);
                }
                frmMusic.Close();
            }

            CountM        = lbMusic.Items.Count;
            tbxCount.Text = CountM.ToString();
        }
Пример #4
0
        /// <summary>
        /// запрос аудио
        /// </summary>
        /// <param name="query">Название группы или песни</param>
        /// <param name="_offset">Смещение поиска</param>
        private void GetAudio(string query, int _offset)
        {
            long i;
            var  _music = new AudioSearchParams();

            _music.Autocomplete = true;
            if (chkAuthor.IsChecked == true)
            {
                _music.PerformerOnly = true;
            }
            _music.Sort   = VkNet.Enums.AudioSort.Popularity;
            _music.Count  = 200;
            _music.Query  = query;
            _music.Offset = _offset;

            var tmpList = App.AuthPublic.Audio.Search(_music, out i);

            foreach (var s in tmpList)
            {
                MusicClass chk = new MusicClass();
                chk.Id       = (int)s.Id;
                chk.Name     = string.Format("{0} - {1}", s.Artist.Trim(), s.Title.Trim());
                chk.Path     = s.Url;
                chk.Duration = String.Format("{0}:{1:00}", s.Duration / 60, s.Duration - ((s.Duration / 60) * 60));

                string _sUrl = s.Url.ToString().Substring(0, s.Url.ToString().IndexOf(".mp3") + 4);

                //TagLib.File _file = TagLib.File.Create(new VfsFileAbstraction());
                //ICodec _codec = (ICodec)_file.Properties.Codecs;
                //IAudioCodec _acodec = _codec as IAudioCodec;

                //chk.Duration = _acodec.AudioBitrate.ToString();

                if (listSearch.Where(p => p.Name.ToLower() == chk.Name.ToLower()).Count() < 1)
                {
                    listSearch.Add(chk);
                }
            }
            lbxMusic.Items.Refresh();
        }
Пример #5
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            listGet.Clear();
            chkAll.IsChecked = false;
            var _audioParams = new AudioGetParams();
            int key          = GetPeopleList.FirstOrDefault(x => x.Value == (string)cmbFri.Text).Key;

            _audioParams.OwnerId = key;
            var _user      = new User();
            var _audioList = App.AuthPublic.Audio.Get(out _user, _audioParams);

            foreach (var s in _audioList)
            {
                MusicClass chk = new MusicClass();
                chk.Id       = (int)s.Id;
                chk.Name     = string.Format("{0} - {1}", s.Artist, s.Title);
                chk.Path     = s.Url;
                chk.Duration = String.Format("{0}:{1:00}", s.Duration / 60, s.Duration - ((s.Duration / 60) * 60));

                listGet.Add(chk);
            }
            lbxGetFriends.Items.Refresh();
        }