2009-04-11 5 views
0

J'ai besoin de lire divers fichiers swf dans une application C#.Pourquoi un fichier SWF en pause C# n'est pas utilisé lors de l'utilisation de AxShockwaveFlash

Ils semblent commencer à bien jouer, mais essayer de faire une pause n'a aucun effet la première fois et blanchit le panneau si j'essaie à nouveau.

Le code que j'utilise est ci-dessous.

Le rembobinage & n'a également aucun effet.

Des commentaires ou de l'aide seraient appréciés.

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

Répondre

1

Je viens développé un projet en C# pour intégrer un objet flash dans un WPF UserControl, qui doit embedd un Windows Forms UserControl pour pouvoir jouer.

Donc, mon expérience est que Stop() methd des axShockwaveFlashObjects est en pause en fait le film et Play() est reprise en fait le film (commence elle a aussi).

Voici le code que je l'utilise dans mon Windows Forms UserControl jouer, Pause, Reprendre et arrêter un objet swf:

/// <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; 
    } 
Questions connexes