开发者

Properly dispose QuickTime control

开发者 https://www.devze.com 2022-12-23 03:31 出处:网络
I\'m currently developing an application for Windows platform that will be able to play Quick Time videos.

I'm currently developing an application for Windows platform that will be able to play Quick Time videos. The targeted OS versions are Windows XP, Windows Vista and Windows 7.

I successfully used the Apple ActiveX QuickTime Control 2.0 (in C#) and everything works well on Windows XP.

However, on Vista and Windows 7 I'm facing problems with properly disposing the control. Here are the "steps to reproduce" : - I create the Quick Time control dynamically at runtime and I place it on a panel;

  • I successfully play videos with it;

  • At some point I close the application main form; the application windows is destroyed and the application will continue to run in the background (doing operations like syncing videos); at this point the control is disposed using IDisposable pattern; I can't explicitly dispose the Movie object (from the ActiveX control) because I get an exception like: "COM object that has been separated from its underlying RCW cannot be used."; I just use (AxQTOControlLib.AxQTControl) player.Dispose(); On Windows XP this is fine but not on Vista and 7

  • I restore my application (from tool bar where it was running in background) and try to open the video again; At this point an AccessViolationException "Attempted to read/write protected memory" is thrown;

My questions are:

  • Why is this happening only on Vista and Windows 7 ?

  • On XP is a hidden leak ?

  • What is the recommended way to dispose the control (with its movie object) when it is created at runtime ?

I'm now using an explicit Movie.Disconnect() call (although I don't now what this disconnect means because I could not find proper documentation) fallowed by a QuickTimeTerminate() call before the form is closed. While my method is working it is kind of design breaking so I would like to know a better way of doing this.

Thank you, Mosu'

U开发者_运维问答pdate: I just discovered that my method is not workink. I use to players: QuickTime control and Windows Media player control (both ActiveX) and when one fails to play a file the other one is used. I was seeing the output of WindowsMedia player and thinking the methos IS working. So my fix is not working at all.


Lots of people seem to be having this error.

This page offers an interesting approach: http://www.theusenetarchive.com/usenet-message-how-to-properly-destroy-quicktime-activex-object-10384503.htm

The crash occurs because of file handles still being open.  I was 'unloading' movies from the Quicktime control by wiring a null string to the FileName or URL property.  Quicktime doesn't handle this correctly and leaves the original file open.  So instead I wired a path to an actual image file (Quicktime does images too) that was all black.  Eveything seems fine now.

0

精彩评论

暂无评论...
验证码 换一张
取 消