这些是播放时候一些用到的东西 你可以参考一下 写的不是很完整亚!(player.cs 类)
class Player
{
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[i] = playList[i + 1];
}
numOfMusic--;
}
public void play(int selectNum)
{
myPlayer.URL = playList[selectNum];
currentPlay = selectNum;
}
public int NextPlay(int type)
{
/* type = 0 顺序
type = 1 重复播放全部
type = 2 重复播放一首
type = 3 随机播放
*/
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;
}
}
}