title: Error with Quicktime when loading movie with c# 2005
body: <p>I have a program that will play videos ".mov" from a queue.  If there are no videos in the queue then the "attract loop" video reloads.  I am using the event handler "qtEventMovieDidEnd" that fires when the movie ends.  This event handler when fired asks if there are any movies in the queue and if not it reloads the attract loop file and is supposed to play it.  My problem is that when the event fires at the end of the movie it tries to reload the file and throws an error "An unhandled exception of type 'System.AccessViolationException' occurred in System.Windows.Forms.dll".  I can remove the event handler and manually load any movie by using a button click event and load it that way, it works perfect when I do that.  The error sends Visual Studio .net 2005 to my "program.cs" file and exits.  It stops at "Application.Run(new Form1()).<br>
  Why does the event handler throw an error but when I manually load a movie it works great?<br>
  The methods in my code:</p>
  
  <pre><code>private void addMovieEventListeners(QTMovie myMovie)
  {
      // Make sure a movie is loaded first
      if (myMovie == null)return;
      myMovie.EventListeners.Add(QTOLibrary.QTEventClassesEnum.qtEventClassStateChange,
          QTEventIDsEnum.qtEventMovieDidEnd, null, null);
  }
  
  public void PlayMovie(string movie)
  {
      axQTControl1.URL = movie;
      addMovieEventListeners(axQTControl1.Movie);
      axQTControl1.Movie.Play(1.0);
      frm1.lblMoviePlaying.Text = axQTControl1.Movie.URL;
  }
  
  private void axQTControl1_QTEvent(object sender, _IQTControlEvents_QTEventEvent e)
  {
      if (e.eventID == (int)QTEventIDsEnum.qtEventMovieDidEnd)
      {
          axQTControl1.Movie.EventListeners.RemoveAll();
          //MessageBox.Show("Movie Ended");
          PlayMovie(@"C:\AttractLoop\AttractLoop.mov");
      }
  }
  </code></pre>