David Knight
David Knight

Reputation:

Why doesn't a SWF file in C# pause when using AxShockwaveFlash

I need to play various swf files in a C# application.

They seem to start playing fine but trying to pause it has no effect the 1st time and whites out the panel if I try again.

The code I'm using is below.

Also rewind & forward have no effect.

Any comments or help would be appreciated.

David Knight

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();
        }
    }
}

Upvotes: 0

Views: 4096

Answers (1)

JoanComasFdz
JoanComasFdz

Reputation: 3066

I've just developed a project in c# to embed a flash object into an WPF UserControl, which has to embedd a Windows Forms UserControl to be able to play it.

So, my experience is that Stop() methd of the axShockwaveFlashObjects is actually pausing the movie and Play() is actually resuming the movie (also is starting it).

Here is the code I use in my Windows Forms UserControl to Play, Pause, Resume and Stop an swf object:

    /// <summary>
    /// Starts playing the movie, or resumes
    /// it if it is paused.
    /// </summary>
    public void Play()
    {
        Stop();
        flash_control.Play();
    }

    /// <summary>
    /// Pauses the movie. To resume it, 
    /// call <see cref="Play()"/>.
    /// </summary>
    public void Pause()
    {
        flash_control.Stop();
    }

    /// <summary>
    /// Stops playing the movie
    /// </summary>
    public void Stop()
    {
        flash_control.Stop();
        flash_control.FrameNum = 0;
    }

Upvotes: 1

Related Questions