private void PreviewDownLoad(NetMusic netMusic)
 {
     if (!netMusic.IsDownLoading && !netMusic.IsDownLoaded)
     {
         netMusic.IsDownLoading = true;;
         Thread thread = new Thread(new ThreadStart(() => DownLoadMusic(netMusic)));
         thread.IsBackground = true;
         thread.Start();
     }
 }
Beispiel #2
0
 public Music(NetMusic music)
 {
     Title         = music.Title;
     Singer        = music.Singer;
     Album         = music.Album;
     AlbumImageUrl = music.AlbumImageUrl;
     Path          = music.Url;
     LyricPath     = music.LyricPath;
     Duration      = music.Duration;
     Origin        = music.Origin;
     MusicID       = music.MusicID;
 }
        private bool IsExist(NetMusic music, out int index)
        {
            var list = this as NetMusicObservableCollection <NetMusic>;

            if (list != null)
            {
                for (int i = 0; i < this.Count; i++)
                {
                    if (list[i].Url == music.Url)
                    {
                        index = i;
                        return(true);
                    }
                }
            }
            index = -1;
            return(false);
        }
        private void DownLoadMusic(NetMusic netMusic)
        {
            var music = NetMusicHelper.GetMusicByNetMusic(netMusic);

            if (music == null)
            {
                return;
            }
            Dispatcher.Invoke(new Action(() =>
            {
                if (!ParentWindow.LocalMusic.FolderList.Contains(Path.GetDirectoryName(music.Path) + "\\"))
                {
                    ParentWindow.LocalMusic.FolderList.Add(Path.GetDirectoryName(music.Path) + "\\");
                }
                ParentWindow.LocalMusic.LocalMusicList.Add(music);
                DownLoadedList.Add(music);
                netMusic.IsDownLoading = false;
                netMusic.IsDownLoaded  = true;
                DownLoadingList.Remove(netMusic);
            }));
        }
Beispiel #5
0
 public DownLoadMusic(NetMusic music) : base(music)
 {
 }
        public bool Play(Music music = null, NetMusic netMusic = null)
        {
            var tmpIndex = CurrentIndex;

            if (music != null)
            {
                CurrentIndex = CurrentMusicList.Add(music);
            }
            else if (netMusic != null)
            {
                CurrentIndex = CurrentMusicList.Add(new Music(netMusic));
            }
            if (CurrentIndex >= 0 && CurrentIndex < CurrentMusicList.Count && CurrentMusicList[CurrentIndex].Origin != NetMusicType.LocalMusic)
            {
                var url = "";
                if (NetMusicHelper.CheckLink(CurrentMusicList[CurrentIndex].Path))
                {
                    url = CurrentMusicList[CurrentIndex].Path;
                }
                else
                {
                    url = NetMusicHelper.GetUrlByNetMusic(CurrentMusicList[CurrentIndex]);
                    if (!NetMusicHelper.CheckLink(url))
                    {
                        CurrentMusicList.RemoveAt(CurrentIndex);
                        CurrentIndex = tmpIndex;
                        Play();
                        return(false);
                    }
                    CurrentMusicList[CurrentIndex].Path = url;
                }
                if (url.Length <= 0)
                {
                    CurrentMusicList.Remove(CurrentMusicList[CurrentIndex]);
                    CurrentIndex = tmpIndex;
                    return(false);
                }
            }
            else if (CurrentMusicList.Count > 0 && (CurrentIndex < 0 || CurrentIndex >= CurrentMusicList.Count))
            {
                CurrentIndex = 0;
            }
            if (CurrentIndex >= 0 && CurrentIndex < CurrentMusicList.Count)
            {
                if (Regex.IsMatch(CurrentMusicList[CurrentIndex].Path, "[http|https]://") && !NetMusicHelper.CheckLink(CurrentMusicList[CurrentIndex].Path))
                {
                    CurrentMusicList[CurrentIndex].Path = string.Empty;
                    return(false);
                }
                bsp.Stop();
                bsp.FileName = CurrentMusicList[CurrentIndex].Path;
                bsp.Play();
                CurrentMusicList[CurrentIndex].Duration = bsp.TotalTime;
                PlayMusicButton.Visibility  = Visibility.Hidden;
                PauseMusicButton.Visibility = Visibility.Visible;
                Title           = CurrentMusicList[CurrentIndex].Title + " - " + CurrentMusicList[CurrentIndex].Singer;
                notifyIcon.Text = Title.Length >= 63 ? Title.Substring(0, 60) + "..." : Title;
                HistoryMusicList.Add(new MusicHistory(CurrentMusicList[CurrentIndex]));
                SetMiniLable(CurrentMusicList[CurrentIndex]);
            }
            return(true);
        }
Beispiel #7
0
 public Music(Music music, NetMusic net_music) : this(music)
 {
     Title  = net_music.Title;
     Singer = net_music.Singer;
     Album  = net_music.Album;
 }