在winform中嵌入player控件,加载页面的时候初始化播放列表,要求播放MP3文件的时候加以控制(听力考试)
比如:
播放完第一个文件后暂停3秒中再播放下一个文件,我通过捕获播放器状态的改变事件回调方法,通过线程的sleep方法来暂停线程,实现上面所说的要求,但是这么做出现了一个问题,线程睡眠的时候,winform界面也不可用了,造成了程序假死的现象,各位大牛,能有什么方法解决这个问题吗?或者换一种方式实现上面的需求,急等!!!!!
附代码如下
protected void myPlayer_StatusChange(object sender, EventArgs e)
{
int k = (int)myPlayer.playState;
if (((int)myPlayer.playState == 8) && this.index < 11)
{
this.index++;
if (this.index % 2 != 0)
{
System.Threading.Thread.Sleep(3000);
myPlayer.Ctlcontrols.play();
}
else
{
System.Threading.Thread.Sleep(11000);
myPlayer.Ctlcontrols.play();
}
}
}
比如:
播放完第一个文件后暂停3秒中再播放下一个文件,我通过捕获播放器状态的改变事件回调方法,通过线程的sleep方法来暂停线程,实现上面所说的要求,但是这么做出现了一个问题,线程睡眠的时候,winform界面也不可用了,造成了程序假死的现象,各位大牛,能有什么方法解决这个问题吗?或者换一种方式实现上面的需求,急等!!!!!
附代码如下
protected void myPlayer_StatusChange(object sender, EventArgs e)
{
int k = (int)myPlayer.playState;
if (((int)myPlayer.playState == 8) && this.index < 11)
{
this.index++;
if (this.index % 2 != 0)
{
System.Threading.Thread.Sleep(3000);
myPlayer.Ctlcontrols.play();
}
else
{
System.Threading.Thread.Sleep(11000);
myPlayer.Ctlcontrols.play();
}
}
}
说的不对,愿大侠们指点呢
学习
学习
myTimer.Tick += new EventHandler(TimerEventProcessor);
protected void myPlayer_StatusChange(object sender, EventArgs e)
{
int k = (int)myPlayer.playState;
if (((int)myPlayer.playState == 8) && this.index < 11)
{
this.index++;
if (this.index % 2 != 0)
{ // Sets the timer interval to 3 seconds.
myTimer.Interval = 3000;
myTimer.Start();
}
else
{
// Sets the timer interval to 11 seconds.
myTimer.Interval = 11000;
myTimer.Start();
}
}
}
// This is the method to run when the timer is raised.
private static void TimerEventProcessor(Object myObject,
EventArgs myEventArgs) {
myTimer.Stop(); myPlayer.Ctlcontrols.play(); }