Windows Media Player 9 in a Multi-threaded Class
Posted on 2003-02-24
Does anyone knows how to launch a Windows Media Player 9 control (to play a movie file) from a Multi-threaded class?
I tried to create an instance of the Windows Media Player ActiveX control in my class as below,
m_objMediaPlayer = New AxWMPLib.AxWindowsMediaPlayer()
but the following error occured:-
Run-time exception thrown : System.Threading.ThreadStateException - Could not instantiate ActiveX control '6bf52a52-394a-11d3-b153-00c04f79faa6' because the current thread is not in a single-threaded apartment.
I have tried the following method too, the Media Player control is displayed and the movie is playing, but I can't get the PlayState and Open State of the Media Player control :-
m_objMediaPlayer = New WMPLib.WindowsMediaPlayer()
Please help, thanks.