tags:

views:

314

answers:

1

Hi,

It took me some time figuring out how to embed QuickTime player in a C# application. When I was very happy about my success the spcifications changed to have custom controls (and not those from Apple QuickTime Control 2.0) for our player.

I searched a lot for examples or documentation but, as usual, there is none from Apple. I thoughth is very straighforward, like this:

if (m_QTPlayer.Movie != null)
{
   m_QTPlayer.QuickTime.QTEvent += new 
          QTOLibrary._IQTObjectEvents_QTEventEventHandler(QuickTime_QTEvent);
   m_QTPlayer.Movie.QTEvent += new               
          QTOLibrary._IQTObjectEvents_QTEventEventHandler(Movie_QTEvent);
 }

but, surprisingly, I get no event in my Movie_QTEvent method.

Is there something that escapes me ? Is hard to believe that is not possible but I can't see how to do it.

Thank you, Mosu'

A: 

I found the answer even if the things are not as great as I hoped they will be.

Here is some code that is self-explanatory:

private void button1_Click(object sender, EventArgs e)
    {
        OpenFileDialog ofd = new OpenFileDialog();
        if (ofd.ShowDialog() == DialogResult.OK)
        {
            axQTControl1.URL = ofd.FileName;

            axQTControl1.Movie.EventListeners.Add(QTEventClassesEnum.qtEventClassAudio,
                QTEventIDsEnum.qtEventAudioBalanceDidChange, null, null);

            axQTControl1.Movie.EventListeners.Add(QTEventClassesEnum.qtEventClassTemporal,
                QTEventIDsEnum.qtEventTimeWillChange, null, null);

            axQTControl1.Movie.EventListeners.Add(QTEventClassesEnum.qtEventClassAudio,
                QTEventIDsEnum.qtEventAudioVolumeDidChange, null, null);

            axQTControl1.Movie.EventListeners.Add(QTEventClassesEnum.qtEventClassApplicationRequest,
                QTEventIDsEnum.qtEventAudioBalanceDidChange, null, null);

            axQTControl1.Movie.EventListeners.Add(QTOLibrary.QTEventClassesEnum.qtEventClassProgress, 
                QTOLibrary.QTEventIDsEnum.qtEventExportProgress, null, null);

            axQTControl1.Movie.EventListeners.Add(QTEventClassesEnum.qtEventClassStateChange,
                QTEventIDsEnum.qtEventMovieDidEnd, null, null);

            axQTControl1.Movie.EventListeners.Add(QTEventClassesEnum.qtEventClassStateChange,
                QTEventIDsEnum.qtEventRateWillChange, null,  null);                                               

        }
    }

    private void axQTControl1_QTEvent(object sender, AxQTOControlLib._IQTControlEvents_QTEventEvent e)
    {
        Console.WriteLine(e.eventID.ToString());
    }

Information on the right combination of Enums can be found here: http://books.google.ro/books?id=WwzK0JopNNAC&pg=PA96&lpg=PA96&dq=qtEventRateWillChange&source=bl&ots=hMWiINDDrX&sig=egFhnlvGX_vJZECx-5HXwxSAioc&hl=ro&ei=jMeQS8mBOKTYmwO2092uCw&sa=X&oi=book_result&ct=result&resnum=3&ved=0CA8Q6AEwAg#v=onepage&q=qtEventRateWillChange&f=false

If the link does not work google books for: "QuickTime for .NET and COM developers by John Cromie"

I was hoping there is an easy way to create a movie time line but until now I could not find it. Hope someone will and post it here.

Thank you, Mosu'

mosu