思路:
1.读取批定路径的目录文件.
2.用List存放.
3.循环List列表添加到播放列表.
public void VidieoPlay()
{
//WindowsMediaPlayer1.uiMode = "none" //隐藏WMP播放器控制面板
//WindowsMediaPlayer1.URL = " " //加载媒体
//WindowsMediaPlayer1.stretchToFit = True
//WindowsMediaPlayer1.enableContextMenu = True ‘允许右键菜单
//WindowsMediaPlayer1.settings.autoStart = False 设置自动播放
//WindowsMediaPlayer1.windowlessVideo = False
//WindowsMediaPlayer1.Controls.play 播放
//WindowsMediaPlayer1.fullScreen = False ‘禁止全屏
string Path = System.Environment.CurrentDirectory + @"\\video"; //音乐或视频路径
IWMPMedia media;
WindowsMediaPlayer1.settings.setMode("loop", true);//设置为循环播放
DirectoryInfo dir = new DirectoryInfo(Path);
List<string> fileName = new List<string>(); //存放文件名.
//循环文件至List列表
foreach (FileInfo f in dir.GetFiles ())
{
fileName.Add(f.Name);
}
foreach (string item in fileName)
{
string FileName = Path + "\\" + item;
media = wmP_Vidieo.newMedia(FileName); //参数为歌曲路径
WindowsMediaPlayer1.currentPlaylist.appendItem(media);//文件添加到当前列表
}
WindowsMediaPlayer1.Ctlcontrols.play(); //开始播放
}