//랜덤재생 시작 private void RandomMusicStart() { try { int nIndex = listBox_PlayList.SelectedIndex; //선택된 인덱스 번호 if (nIndex < 0) //선택된 인덱스의 파일경로를 통해 audio객체생성 { MessageBox.Show("재생할 곡을 선택해 주세요.", "재 생"); return; } int RandomNum = Randomnum.Next(1, 999); //랜덤 난수 생성 while(true) //랜덤시 중복배제 { if (tempRandomnum == tempRandomnum % listBox_PlayList.Items.Count) { RandomNum = Randomnum.Next(1, 999); tempRandomnum = RandomNum; } if (tempRandomnum != tempRandomnum % listBox_PlayList.Items.Count) break; } if (!bCheckPause) //음악이 일시정지 상태가 아닐때 { if (audio != null)// 오디오객체가 있을때 { audio.Stop(); // 재생중인 오디오를 멈추고 audio.Close(); //재생하지않을때 메모리 차지하지 않게 } audio = new Audio_Class(); //새 오디오객체 생성 timer1.Start();//타이머1 시작 //장치 오픈 if (!audio.Open((string)aFilePathList[RandomNum % listBox_PlayList.Items.Count])) //선택된 인덱스의 파일경로를 통해 audio객체생성할 수 없을때 { MessageBox.Show("재생할 수 없는 곡입니다.", "재 생"); return; //audio.Open((string)aFilePathList[RandomNum % listBox_PlayList.Items.Count])실행 } textBox_Title.Text = aFileNameList[RandomNum % listBox_PlayList.Items.Count].ToString(); //제목창에 선택재생된 인덱스를 출력 //child.TxtName.Text = listBox_PlayList.SelectedItem.ToString();//가사창에 선택재생된 인덱스를 출력 } int nVolume = TrackBarSound.Value * 30; // 트랙바를 통한 사운드값 조정 audio.SetVolume(nVolume); audio.play(); //음악재생 시작 leftTime = audio.GetLength() / 1000;// 남은시간(hour) timer1.Start(); //타이머1 시작 bCheckPause = false; //일시정지상태 아님 if (Lyric.GetLyricsFromFile(((string)aFilePathList[RandomNum % listBox_PlayList.Items.Count]), child.ckViewTime1.Checked)) { fLyricLists = null; fLyricLists = Lyric.LyricLists; child.TxtLyric.Text = fLyricLists[0]; } tempRandomnum = RandomNum; } catch { } }
private void PreviousButtonMusicStart() { --nowplaynum; //nowplaynum 1 감소 try { if (nowplaynum < 0) { nowplaynum = aFileNameList.Count -1; } if (selectnum < 0) //선택된 인덱스의 파일경로를 통해 audio객체생성 { MessageBox.Show("재생할 곡을 선택해 주세요.", "재 생"); return; } if (!bCheckPause) //음악이 일시정지 상태가 아닐때 { if (audio != null)// 오디오객체가 있을때 { audio.Stop();// 재생중인 오디오를 멈추고 audio.Close();//재생하지않을때 메모리 차지하지 않게 } audio = new Audio_Class(); //새 오디오객체 생성 timer1.Start(); //timer1 시작 //장치 오픈 //if (!audio.Open((string)aFilePathList[listBox_PlayList.SelectedIndex + nowplaynum])) //선택된 인덱스의 파일경로를 통해 audio객체생성할 수 없을때 if (!audio.Open((string)aFilePathList[selectnum + nowplaynum])) { MessageBox.Show("재생할 수 없는 곡입니다.", "재 생"); return; //audio.Open((string)aFilePathList[listBox_PlayList.SelectedIndex + nowplaynum]) 실행 } //제목 창 출력 textBox_Title.Text = aFileNameList[selectnum + nowplaynum].ToString(); //제목창에 선택재생된 인덱스를 출력 //child.TxtName.Text = listBox_PlayList.SelectedItem.ToString();//가사창에 선택재생된 인덱스를 출력 } //재생 audio.SetVolume(200); //오디오의 시작볼륨 audio.play(); //음악재생 시작 leftTime = audio.GetLength() / 1000;// 남은시간(hour) timer1.Start(); //타이머1 시작 bCheckPause = false; //일시정지상태 아님 try { if (Lyric.GetLyricsFromFile(((string)aFilePathList[selectnum + nowplaynum]), child.ckViewTime1.Checked)) { fLyricLists = null; fLyricLists = Lyric.LyricLists; child.TxtLyric.Text = fLyricLists[0]; } } catch { child.TxtLyric.Text = "가사를 찾을 수 없습니다."; } } catch { nowplaynum = 0; } }
private void PreviousMusicStart() { int nIndex = listBox_PlayList.SelectedIndex; //선택된 인덱스 번호 if (nIndex < 0) //선택된 인덱스의 파일경로를 통해 audio객체생성 { MessageBox.Show("재생할 곡을 선택해 주세요.", "재 생"); return; } audio.Stop();// 재생중인 오디오를 멈추고 audio.Close();//재생하지않을때 메모리 차지하지 않게 audio = new Audio_Class(); //새 오디오객체 생성 timer1.Start(); //timer1 시작 //장치 오픈 if (!audio.Open((string)aFilePathList[listBox_PlayList.SelectedIndex + nowplaynum])) //선택된 인덱스의 파일경로를 통해 audio객체생성할 수 없을때 { MessageBox.Show("재생할 수 없는 곡입니다.", "재 생"); return; //audio.Open((string)aFilePathList[listBox_PlayList.SelectedIndex + nowplaynum]) 실행 } //제목 창 출력 textBox_Title.Text = listBox_PlayList.SelectedItem.ToString(); //제목창에 선택재생된 인덱스를 출력 //child.TxtName.Text = listBox_PlayList.SelectedItem.ToString();//가사창에 선택재생된 인덱스를 출력 //재생 int nVolume = TrackBarSound.Value * 30; // 트랙바를 통한 사운드값 조정 audio.SetVolume(nVolume); nowplaynum++; //nowplaynum 1 증가 audio.play(); //음악재생 시작 leftTime = audio.GetLength() / 1000;// 남은시간(hour) timer1.Start(); //타이머1 시작 bCheckPause = false; //일시정지상태 아님 if (Lyric.GetLyricsFromFile(((string)aFilePathList[listBox_PlayList.SelectedIndex + nowplaynum]), child.ckViewTime1.Checked)) { fLyricLists = null; fLyricLists = Lyric.LyricLists; child.TxtLyric.Text = fLyricLists[0]; } }
//한곡재생 private void MusicStart() { try { nowplaynum = listBox_PlayList.SelectedIndex; int nIndex = listBox_PlayList.SelectedIndex; //선택된 인덱스 번호 if (repeatnum < 0) //선택한 인덱스가 없을때 { MessageBox.Show("재생할 곡을 선택해 주세요.", "재 생"); return; } if (!bCheckPause) //음악이 일시정지 상태가 아닐때 { if (audio != null) // 오디오객체가 있을때 { audio.Stop(); // 재생중인 오디오를 멈추고 audio.Close();//재생하지않을때 메모리 차지하지 않게 } audio = new Audio_Class(); //새 오디오객체 생성 timer1.Start(); //timer1 시작 //장치 오픈 if (!audio.Open((string)aFilePathList[repeatnum])) //선택된 인덱스의 파일경로를 통해 audio객체생성할 수 없을때 { MessageBox.Show("재생할 수 없는 곡입니다.", "재 생"); return;//audio.Open((string)aFilePathList[listBox_PlayList.SelectedIndex]) 실행 } textBox_Title.Text = listBox_PlayList.Items[repeatnum].ToString();//제목창에 선택재생된 인덱스를 출력 //child.TxtName.Text = listBox_PlayList.SelectedItem.ToString();//가사창에 선택재생된 인덱스를 출력 } //재생 int nVolume = TrackBarSound.Value * 30; // 트랙바를 통한 사운드값 조정 audio.SetVolume(nVolume); audio.play();//음악재생 시작 leftTime = audio.GetLength() / 1000; // 남은시간(hour) timer1.Start();//타이머1 시작 bCheckPause = false;//일시정지상태 아님 if (Lyric.GetLyricsFromFile(((string)aFilePathList[repeatnum]), child.ckViewTime1.Checked)) { fLyricLists = null; fLyricLists = Lyric.LyricLists; child.TxtLyric.Text = fLyricLists[0]; } } catch { } //Gasa = Lyric.GetFileLyrics((string)aFilePathList[listBox_PlayList.SelectedIndex]).Split(new string[] { " <br> " }, StringSplitOptions.RemoveEmptyEntries); // files = openFileDialog1.SafeFileNames; // 열기 대화상자에서 선택한 파일 이름들을 모두 가져옴 //for (int i = 0; i < Gasa.Length; i++) //for문을 이용해 가져온 파일 이름을 listbox에 추가시킴 //{ // child.TxtLyric.Text = Gasa[i]; //} //child.TxtLyric.Text = Gasa; }