我需要在 C# 应用程序中播放各种 swf 文件。
他们似乎开始玩得很好,但第一次尝试暂停它没有效果,如果我再试一次,面板就会变白。
我正在使用的代码如下。
倒带和前进也没有效果。
任何意见或帮助将不胜感激。
大卫奈特
namespace MyUI
{
public partial class ABWithSWF : MyAbstractABFrm
{
// Keep Track of whats happening
enum StateOfPlay {NotSet, Playing, Paused };
private AxShockwaveFlashObjects.AxShockwaveFlash axShockwaveFlashCube = new AxShockwaveFlashObjects.AxShockwaveFlash();
StateOfPlay playState = StateOfPlay.NotSet;
public ABWithSWF()
{
InitializeComponent();
pnlSwf.Controls.Add(axShockwaveFlashCube);
axShockwaveFlashCube.Dock = DockStyle.Fill;
}
// One button that is either play or pause
private void btnPlay_Click(object sender, EventArgs e)
{
// File to play
string path = string.Format(@"{0}\graphical summary.swf", Utils.GetSWFPath());
switch (playState)
{
case StateOfPlay.Paused:
axShockwaveFlashCube.Play();
btnPlay.ImageIndex = 3;
playState = StateOfPlay.Playing;
break;
case StateOfPlay.Playing:
axShockwaveFlashCube.StopPlay();
btnPlay.ImageIndex = 4;
playState = StateOfPlay.Paused;
break;
case StateOfPlay.NotSet:
axShockwaveFlashCube.LoadMovie(0, path);
axShockwaveFlashCube.Play();
btnPlay.ImageIndex = 4;
playState = StateOfPlay.Playing;
break;
}
}
private void button2_Click(object sender, EventArgs e)
{
axShockwaveFlashCube.Rewind();
}
private void button3_Click(object sender, EventArgs e)
{
axShockwaveFlashCube.Forward();
}
}
}