{
private AxWMPLib.AxWindowsMediaPlayer myPlayer;
private
string
[] playList;
private int numOfMusic;
private int currentPlay;
public int NumOfMusic
{
get
{
return numOfMusic;
}
}
public WMPLib.WMPPlayState playstate
{
get
{
return myPlayer.playState;
}
}
public string PlayList(int num)
{
return playList[num];
}
public Player(AxWMPLib.AxWindowsMediaPlayer mediaPlayer)
{
myPlayer = mediaPlayer;
playList = new string[1000];
numOfMusic = 0;
}
public
void
AddFile(string path)
{
if(numOfMusic < 1000)
{
numOfMusic ;
playList[numOfMusic] = path;
}
}
public void DelFile(int selectNum)
{
for(int i = selectNum; i <= numOfMusic - 1; i )
{
playList = playList[i 1];
}
numOfMusic --;
}
public void play(int selectNum)
{
myPlayer.URL = playList[selectNum];
currentPlay = selectNum;
}
public int NextPlay(int type)
{
/* type = 0 順序
switch
(type)
{
case 0:
currentPlay ;
if(currentPlay > numOfMusic)return 0;
else return currentPlay;
case 1:
currentPlay ;
if(currentPlay > numOfMusic) return 1;
else return currentPlay;
case 2:
return currentPlay;
case 3:
Random rdm = new Random(unchecked((int)DateTime.Now.Ticks));
currentPlay = rdm.Next() % numOfMusic;
if(currentPlay == 0) return numOfMusic;
else return currentPlay;
default:
return 0;
}
}
}
if(this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
string path = this.openFileDialog1.FileName;
FileInfo f = new FileInfo(path);
MyPlayer.AddFile(f.FullName);
string STRFILE = Convert.ToString(MyPlayer.NumOfMusic);
for(int i = 1;i<=5-STRFILE.Length;i )STRFILE =’ ’;
STRFILE = f.Name;
this.listBox1.Items.Add(STRFILE);
}
if(this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
string path = this.openFileDialog1.FileName;
FileInfo f = new FileInfo(path);
MyPlayer.AddFile(f.FullName);
string STRFILE = Convert.ToString(MyPlayer.NumOfMusic);
for(int i = 1;i<=5-STRFILE.Length;i )STRFILE =’ ’;
STRFILE = f.Name;
this.listBox1.Items.Add(STRFILE);
}
if(this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
string path = this.openFileDialog1.FileName;
FileInfo f = new FileInfo(path);
MyPlayer.AddFile(f.FullName);
string STRFILE = Convert.ToString(MyPlayer.NumOfMusic);
for(int i = 1;i<=5-STRFILE.Length;i )STRFILE =’ ’;
STRFILE = f.Name;
this.listBox1.Items.Add(STRFILE);
}
if(this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
string path = this.openFileDialog1.FileName;
FileInfo f = new FileInfo(path);
MyPlayer.AddFile(f.FullName);
string STRFILE = Convert.ToString(MyPlayer.NumOfMusic);
for(int i = 1;i<=5-STRFILE.Length;i )STRFILE =’ ’;
STRFILE = f.Name;
this.listBox1.Items.Add(STRFILE);
}
if(this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
string path = this.openFileDialog1.FileName;
FileInfo f = new FileInfo(path);
MyPlayer.AddFile(f.FullName);
string STRFILE = Convert.ToString(MyPlayer.NumOfMusic);
for(int i = 1;i<=5-STRFILE.Length;i )STRFILE =’ ’;
STRFILE = f.Name;
this.listBox1.Items.Add(STRFILE);
}
if(this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
string path = this.openFileDialog1.FileName;
FileInfo f = new FileInfo(path);
MyPlayer.AddFile(f.FullName);
string STRFILE = Convert.ToString(MyPlayer.NumOfMusic);
for(int i = 1;i<=5-STRFILE.Length;i )STRFILE =’ ’;
STRFILE = f.Name;
this.listBox1.Items.Add(STRFILE);
}
if(this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
string path = this.openFileDialog1.FileName;
FileInfo f = new FileInfo(path);
MyPlayer.AddFile(f.FullName);
string STRFILE = Convert.ToString(MyPlayer.NumOfMusic);
for(int i = 1;i<=5-STRFILE.Length;i )STRFILE =’ ’;
STRFILE = f.Name;
this.listBox1.Items.Add(STRFILE);
}