Exemplo n.º 1
0
        public PageCloudMusicViewModel()
        {
            //这里添加几个 测试的云盘歌曲

            MusicList.Add(new Model.Music()
            {
                Album    = "SoundLift s High State Mix",
                Title    = "Summer Kisses (SoundLift s High State Mix)",
                Artist   = "Eric de la Vega",
                Size     = 4946933,
                TimeStr  = "05:09",
                Index    = "01",
                Url      = "https://raw.githubusercontent.com/944095635/TEST/master/Eric%20de%20la%20Vega%20-%20Summer%20Kisses%20(SoundLift%20s%20High%20State%20Mix)%20Midnight%20Coast.mp3",
                FileName = "Summer Kisses.mp3"
            });
            MusicList.Add(new Model.Music()
            {
                Album    = "变形金刚",
                Title    = "变形金刚塞伯特传奇",
                Artist   = "变形金刚",
                Size     = 641184,
                TimeStr  = "00:32",
                Index    = "02",
                Url      = "https://raw.githubusercontent.com/944095635/TEST/master/Transformers30secsR3.mp3",
                FileName = "Transformers30secsR3.mp3"
            });

            ShowMusicList();
        }
Exemplo n.º 2
0
        private void ReadSavedMusicList()
        {
            if (_musicList != null)
            {
                _musicList.Clear();
            }

            string path = Path.Combine(Helper.ProjectPath, _playListFile);

            if (File.Exists(path) == false)
            {
                return;
            }

            using (StreamReader reader = new StreamReader(path))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    string[] items = line.Split('\t');
                    if (items == null || items.Length != 2)
                    {
                        continue;
                    }

                    string title   = items[0];
                    string address = items[1];
                    MusicList.Add(new PlayerModel(title, address));
                }
            }
        }
Exemplo n.º 3
0
 public Playlist(string name, MusicFile[] files)
 {
     Name = name;
     foreach (var item in files)
     {
         MusicList.Add(item);
     }
 }
Exemplo n.º 4
0
        private async void LoadData()
        {
            HttpClient client = new HttpClient();
            var        json   = await client.GetStringAsync(new Uri("http://localhost:5000/api/Media/music"));

            var musiclist = JsonConvert.DeserializeObject <IList <Music> >(json);

            foreach (var song in musiclist)
            {
                MusicList.Add(song);
            }
            FillCategoryListMusicList();
        }
Exemplo n.º 5
0
 public DataGridViewPageModel()
 {
     //这里添加几个 测试的云盘歌曲
     for (int i = 0; i < 10; i++)
     {
         MusicList.Add(new Item
         {
             Code        = "1",
             Name        = "你好",
             Description = "张雨生档青年为表达爱情"
         });
     }
     ShowMusicList();
 }
Exemplo n.º 6
0
        private void ShowSearchView()
        {
            SearchView view = new SearchView();

            view.ViewModel.RequestSave += (string title, string url) =>
            {
                if (title != null && url != null)
                {
                    MusicList.Add(new PlayerModel(title, url));
                }
            };
            view.ViewModel.RequestClose += (bool result) =>
            {
                view.Close();
            };
            view.Show();
        }
Exemplo n.º 7
0
        private void FindMusic(List <string> filelist)
        {
            int          index    = 1;
            List <Music> TempList = new List <Music>();

            foreach (var item in filelist)
            {
                FileInfo file = new FileInfo(item);

                MP3Info m = new MP3Info();
                m.GetMP3Info(file.DirectoryName, file.Name);

                if (file.Extension.Contains(".mp3"))
                {
                    TempList.Add(new Music()
                    {
                        Title   = m.trackName,
                        Size    = file.Length,
                        Index   = index.ToString(),
                        Url     = file.FullName,
                        Album   = m.Album,
                        Artist  = m.Artist,
                        TimeStr = m.time
                    });
                    index++;
                }
            }
            if (TempList.Count > 0)
            {
                Execute.OnUIThread(() =>
                {
                    foreach (var item in TempList)
                    {
                        if (MusicList.Where(p => p.Title == item.Title).Count() == 0)
                        {
                            MusicList.Add(item);
                        }
                    }
                    //显示歌曲列表
                    ShowMusicList();
                    //保存找到的歌曲
                    Save();
                });
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// 读取配置
 /// </summary>
 public void Read()
 {
     if (File.Exists("LocalMusic.json"))
     {
         //尝试从 配置文件中读取 上次 增加的 播放列表
         string json = File.ReadAllText("LocalMusic.json");
         if (!string.IsNullOrEmpty(json))
         {
             List <Music> list = JsonConvert.DeserializeObject <List <Music> >(json);
             foreach (var item in list)
             {
                 MusicList.Add(item);
             }
             //显示歌曲列表
             ShowMusicList();
         }
     }
 }
Exemplo n.º 9
0
 public Playlist(string name, MusicFile file)
 {
     Name = name;
     MusicList.Add(file);
 }