Exemplo n.º 1
0
        private void lvMusic_DragDrop(object sender, DragEventArgs e)
        {
            if (btnPlay.Enabled == false || btnPrevious.Enabled == false || btnNext.Enabled == false)
            {
                btnPrevious.Enabled = true;
                btnNext.Enabled     = true;
                btnPlay.Enabled     = true;

                form_Mini.btnMiniPrevious.Enabled = true;
                form_Mini.btnMiniNext.Enabled     = true;
                form_Mini.btnMiniPlay.Enabled     = true;
            }
            string[] filenames = (string[])e.Data.GetData(DataFormats.FileDrop, false);
            foreach (string filename in filenames)
            {
                try
                {
                    Load_Mp3Info(filename, lvMusic);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            ExtensionClass.shuffleIndex(randomList, lvMusic);
            ExtensionClass.shuffle(randomList);
        }
Exemplo n.º 2
0
 private void btnNext_Click(object sender, EventArgs e)
 {
     if (modeNum == 3)
     {
         lvMusic.Items[index].Selected = false;
         shuffleindex++;
         if (shuffleindex == randomList.Count)
         {
             ExtensionClass.shuffle(randomList);
             shuffleindex = 0;
         }
         lvMusic.Items[randomList[shuffleindex]].Selected = true;
         index = lvMusic.SelectedItems[0].Index;
         PlayMusic(lvMusic.Items[randomList[shuffleindex]].SubItems[3].Text);
     }
     else
     {
         lvMusic.Items[index].Selected = false;
         index++;
         if (index > lvMusic.Items.Count - 1)
         {
             index = 0;
         }
         lvMusic.Items[index].Selected = true;
         index = lvMusic.SelectedItems[0].Index;
         PlayMusic(lvMusic.Items[index].SubItems[3].Text);
     }
 }
Exemplo n.º 3
0
        void fileDownloadCompleted(object sender, AsyncCompletedEventArgs e)
        {
            nowDownloading = false;

            if (btnPlay.Enabled == false || btnPrevious.Enabled == false || btnNext.Enabled == false)
            {
                btnPrevious.Enabled = true;
                btnNext.Enabled     = true;
                btnPlay.Enabled     = true;

                form_Mini.btnMiniPrevious.Enabled = true;
                form_Mini.btnMiniNext.Enabled     = true;
                form_Mini.btnMiniPlay.Enabled     = true;
            }

            try
            {
                Load_Mp3Info(downfileUrl, lvMusic);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            ExtensionClass.shuffleIndex(randomList, lvMusic);
            ExtensionClass.shuffle(randomList);

            Toast.show(this, "나도 가수다", System.IO.Path.GetFileName(downfileUrl) + "의 다운로드가 완료되었습니다.", ToastType.INFO, ToastDuration.SHORT);
            //MessageBox.Show("파일 다운로드 완료!", "오류", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemplo n.º 4
0
        private void LoadXml()
        {
            if (File.Exists(gStrXmlFilePath))
            {
                XDocument xdoc = XDocument.Load(gStrXmlFilePath);

                IEnumerable <XElement> emps = xdoc.Root.Elements();

                foreach (var emp in emps)
                {
                    string path      = emp.Element("MusicPath").Value;
                    int    count     = 0;
                    string playCount = emp.Element("PlayCount").Value;
                    try
                    {
                        if (path.StartsWith("http"))
                        {
                            ListViewItem lsv = new ListViewItem();
                            lsv.SubItems.Add(path);
                            lsv.SubItems.Add(path);
                            lsv.SubItems.Add(path);
                            lvMusic.Items.Add(lsv);

                            for (int i = 0; i < lvMusic.Items.Count; i++)
                            {
                                lvMusic.Items[i].SubItems[0].Text = (i + 1).ToString();
                            }
                        }
                        else if (path.EndsWith(".mp3"))
                        {
                            Load_Mp3Info(path, lvMusic);
                        }
                        lvMusic.Items[count].SubItems[4].Text = playCount;
                        count++;
                    }
                    catch (Exception ex)
                    {
                        //MessageBox.Show(ex.Message);
                    }
                }
            }
            if (lvMusic.Items.Count > 0)
            {
                btnPrevious.Enabled = true;
                btnNext.Enabled     = true;
                btnPlay.Enabled     = true;

                form_Mini.btnMiniPrevious.Enabled = true;
                form_Mini.btnMiniNext.Enabled     = true;
                form_Mini.btnMiniPlay.Enabled     = true;


                ExtensionClass.shuffleIndex(randomList, lvMusic);
                ExtensionClass.shuffle(randomList);
            }
        }
Exemplo n.º 5
0
        private void 삭제ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (lvMusic.SelectedItems.Count <= 0)
            {
                MessageBox.Show("선택된 노래가 없습니다");
                return;
            }
            int index = lvMusic.SelectedIndices[0]; // 선택된 첫번째 레코드의 인덱스

            //index = LV.FocusedItem.Index;
            foreach (ListViewItem row in lvMusic.SelectedItems)
            {
                lvMusic.Items.Remove(row);       // 선택한 행 삭제
            }
            ExtensionClass.listView_No(lvMusic); // 번호 다시 매기기
            if (index > lvMusic.Items.Count - 1)
            {
                index = lvMusic.Items.Count - 1;
            }
            if (lvMusic.Items.Count != 0)
            {
                lvMusic.Items[index].Selected = true;
                lvMusic.Items[index].EnsureVisible();
            }

            if (lvMusic.Items.Count == 0)
            {
                btnPrevious.Enabled = false;
                btnNext.Enabled     = false;

                form_Mini.btnMiniPrevious.Enabled = false;
                form_Mini.btnMiniNext.Enabled     = false;

                if (this.wavePlayer == null)
                {
                    btnPlay.Enabled = false;

                    form_Mini.btnMiniPlay.Enabled = false;
                }
            }
        }
Exemplo n.º 6
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            //index = listView1.SelectedItems[0].Index;
            if (reader != null)
            {
                lblNowTime.Text = FormatTimeSpan(reader.CurrentTime);

                musicBar.Value = Math.Min((int)((musicBar.MaximumValue * reader.Position) / reader.Length), musicBar.MaximumValue);

                //미니폼
                form_Mini.lblNowTime.Text    = FormatTimeSpan(reader.CurrentTime);
                form_Mini.miniTrackBar.Value = Math.Min((int)((musicBar.MaximumValue * reader.Position) / reader.Length), musicBar.MaximumValue);

                if (FormatTimeSpan(reader.CurrentTime) == FormatTimeSpan(reader.TotalTime))
                {
                    if (lvMusic.Items.Count == 0)
                    {
                        btnPrevious.Enabled = false;
                        btnNext.Enabled     = false;
                        btnPlay.Enabled     = false;

                        form_Mini.btnMiniPrevious.Enabled = false;
                        form_Mini.btnMiniNext.Enabled     = false;
                        form_Mini.btnMiniPlay.Enabled     = false;

                        musicBar.Value    = 0;
                        lblTotalTime.Text = "00:00";
                        lblTitle.Text     = "현재 재생중인 곡이 없습니다.";
                        lblArtist.Text    = null;
                        picAlbum.Image    = null;

                        btnPlay.IconChar = FontAwesome.Sharp.IconChar.PlayCircle;

                        return;
                    }

                    lvMusic.Items[index].SubItems[4].Text = (Int32.Parse(lvMusic.Items[index].SubItems[4].Text) + 1).ToString();

                    switch (modeNum)
                    {
                    case 0:
                        if (index < lvMusic.Items.Count - 1)
                        {
                            Thread.Sleep(1000);
                            lvMusic.Items[index].Selected = false;
                            index++;
                            lvMusic.Items[index].Selected = true;
                            PlayMusic(lvMusic.Items[index].SubItems[3].Text);
                        }
                        else if (index >= lvMusic.Items.Count - 1)
                        {
                            musicBar.Value    = 0;
                            lblTotalTime.Text = "00:00";
                            lblTitle.Text     = "현재 재생중인 곡이 없습니다.";
                            lblArtist.Text    = null;
                            picAlbum.Image    = null;

                            btnPlay.IconChar = FontAwesome.Sharp.IconChar.PlayCircle;
                        }
                        break;

                    case 1:
                        Thread.Sleep(1000);
                        PlayMusic(lvMusic.Items[index].SubItems[3].Text);
                        break;

                    case 2:
                        if (index < lvMusic.Items.Count - 1)
                        {
                            Thread.Sleep(1000);
                            lvMusic.Items[index].Selected = false;
                            index++;
                            lvMusic.Items[index].Selected = true;
                            PlayMusic(lvMusic.Items[index].SubItems[3].Text);
                        }
                        else if (index == lvMusic.Items.Count - 1)
                        {
                            Thread.Sleep(1000);
                            lvMusic.Items[index].Selected = false;
                            index = 0;
                            lvMusic.Items[index].Selected = true;
                            PlayMusic(lvMusic.Items[index].SubItems[3].Text);
                        }
                        break;

                    case 3:
                        if (shuffleindex == randomList.Count - 1)
                        {
                            ExtensionClass.shuffle(randomList);
                            shuffleindex = -1;
                        }
                        else if (shuffleindex < randomList.Count - 1)
                        {
                            Thread.Sleep(1000);
                            lvMusic.Items[index].Selected = false;
                            shuffleindex++;
                            lvMusic.Items[randomList[shuffleindex]].Selected = true;
                            index = lvMusic.SelectedItems[0].Index;
                            PlayMusic(lvMusic.Items[randomList[shuffleindex]].SubItems[3].Text);
                        }
                        break;
                    }
                }
            }
            if (this.wavePlayer.PlaybackState == NAudio.Wave.PlaybackState.Playing)
            {
                DisableSaver();
            }
            else if (this.wavePlayer.PlaybackState == NAudio.Wave.PlaybackState.Paused || this.wavePlayer.PlaybackState == NAudio.Wave.PlaybackState.Stopped)
            {
                EnableSaver();
            }
        }
Exemplo n.º 7
0
        public void PlayMusic(string audioFile)
        {
            MusicFile     = audioFile;
            PlayingMusic  = audioFile;
            GetWavePlayer = wavePlayer;
            GetReader     = reader;

            lblInfo.Visible = false;

            if (MusicFile != string.Empty)
            {
                if (File.Exists(MusicFile))
                {
                    musicBar.Value = 0;

                    Load_MusicInfo();

                    if (this.wavePlayer != null)
                    {
                        CleanUp();
                    }

                    Debug.Assert(this.wavePlayer == null);

                    this.wavePlayer = new WaveOut();
                    this.reader     = new AudioFileReader(MusicFile);
                    //this.reader.Volume = volumeSlider1.Value / 100.0F;
                    wavePlayer.Volume = volumeSlider.Value / 100.0F;
                    this.wavePlayer.Init(reader);
                    this.wavePlayer.PlaybackStopped += wavePlayer_PlaybackStopped;
                    this.wavePlayer.Play();
                    timer1.Enabled = true;

                    //btnPlay.Text = "ll";
                    btnPlay.IconChar = FontAwesome.Sharp.IconChar.PauseCircle;
                    form_Mini.btnMiniPlay.IconChar = FontAwesome.Sharp.IconChar.PauseCircle;

                    btnCheck.PerformClick();
                }
                else
                {
                    if (MessageBox.Show("파일을 찾을 수 없습니다. 목록에서 삭제하시겠습니까?\n(파일이 삭제되었거나 다른 위치로 이동되었습니다.)", "나도가수다", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.Cancel)
                    {
                        switch (modeNum)
                        {
                        case 0:
                            if (index < lvMusic.Items.Count - 1)
                            {
                                Thread.Sleep(1000);
                                lvMusic.Items[index].Selected = false;
                                index++;
                                lvMusic.Items[index].Selected = true;
                                PlayMusic(lvMusic.Items[index].SubItems[3].Text);
                            }
                            break;

                        case 1:
                            break;

                        case 2:
                            if (index < lvMusic.Items.Count - 1)
                            {
                                Thread.Sleep(1000);
                                lvMusic.Items[index].Selected = false;
                                index++;
                                lvMusic.Items[index].Selected = true;
                                PlayMusic(lvMusic.Items[index].SubItems[3].Text);
                            }
                            else if (index == lvMusic.Items.Count - 1)
                            {
                                Thread.Sleep(1000);
                                lvMusic.Items[index].Selected = false;
                                index = 0;
                                lvMusic.Items[index].Selected = true;
                                PlayMusic(lvMusic.Items[index].SubItems[3].Text);
                            }
                            break;

                        case 3:
                            if (shuffleindex == randomList.Count - 1)
                            {
                                ExtensionClass.shuffle(randomList);
                                shuffleindex = -1;
                            }
                            else if (shuffleindex < randomList.Count - 1)
                            {
                                Thread.Sleep(1000);
                                lvMusic.Items[index].Selected = false;
                                shuffleindex++;
                                lvMusic.Items[randomList[shuffleindex]].Selected = true;
                                index = lvMusic.SelectedItems[0].Index;
                                PlayMusic(lvMusic.Items[randomList[shuffleindex]].SubItems[3].Text);
                            }
                            break;
                        }
                    }
                    else
                    {
                        lvMusic.Items.RemoveAt(index);
                        ExtensionClass.listView_No(lvMusic);  // 번호 다시 매기기
                        if (index > lvMusic.Items.Count - 1)
                        {
                            index = lvMusic.Items.Count - 1;
                        }
                        if (lvMusic.Items.Count != 0)
                        {
                            lvMusic.Items[index].Selected = true;
                            lvMusic.Items[index].EnsureVisible();
                        }
                        if (this.wavePlayer == null && lvMusic.Items.Count == 0)
                        {
                            btnPrevious.Enabled = false;
                            btnNext.Enabled     = false;
                            btnPlay.Enabled     = false;
                        }
                    }
                }
            }
        }