c#如何实现循环播放n个视频,点击时会弹出图片
戈衔 2018-04-14 09:19:34 using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using AxWMPLib;
namespace ChA3_多媒体播放器
{
public partial class FrmA301多媒体播放器 : Form
{
//C#如何获取指定路径文件夹下的所有文件名
//string[] s = Directory.GetFiles(DirFullPath, SearchPattern);
string[] s = Directory.GetFiles(@"G:\c\ChA3_多媒体播放器改能播放视频无图片\ChA3_多媒体播放器\bin\source\shipin");
string[] pic = Directory.GetFiles(@"G:\c\ChA3_多媒体播放器改能播放视频无图片\ChA3_多媒体播放器\bin\source\picture");
int index = 0; //播放视频的序号
int picindex = 0;//图片序号
public FrmA301多媒体播放器()
{
InitializeComponent();
}
private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
{
player.Ctlcontrols.pause();//暂停视频播放
player.Visible = false;//隐藏视频
picBox.Visible = true; //显示图片
//picBox.SizeMode
picBox.ImageLocation = pic[picindex];
picindex++;
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void test_Click(object sender, EventArgs e)
{
play(index);
//for (int i = 1; i < s.Length; i++)
//{
// if (s[i].EndsWith("wmv")) //过滤掉.db的文件
// {
// play(i);
// }
//}
}
private void play(int number)
{
index++;
player.URL = s[index];
}
private void example_Click(object sender, EventArgs e)
{
player.URL = s[0];//演示视频
}
private void picBox_Click(object sender, EventArgs e)
{
//picBox.Visible = true;//隐藏图片
//player.Visible = false;//显示视频
picBox.Visible = false;//隐藏图片
player.Visible = true;//显示视频
player.Ctlcontrols.play();//继续播放视频
double j = player.currentMedia.duration;
//MessageBox.Show(Convert.ToString(j));
System.Threading.Thread.Sleep(1000 * (int)player.currentMedia.duration);
//System.Threading.Thread.Sleep(1000*(int)player.currentMedia.duration- player.currentMedia.getMarkerTime());
play(index);
}
private void State()
{
//double j = player.currentMedia.duration;
//MessageBox.Show(Convert.ToString(j));
// System.Threading.Thread.Sleep((int)player.currentMedia.duration);
// int j = (int)player.playState;
play(index);
// timer1.Start();
// timer1.Stop();
}
}
}