Windows Media Player

Dave

Member
Joined
Jan 19, 2003
Messages
23
Im trying to use the Windows Media Player ActiveX control in VB.net, but when I try and use it the following exception occurs:

InvalidActiveXStateException

on the line:

AxWindowsMediaPlayer1.enabled = True

Any ideas?
 
Dave said:
Im trying to use the Windows Media Player ActiveX control in VB.net, but when I try and use it the following exception occurs:

InvalidActiveXStateException

on the line:

AxWindowsMediaPlayer1.enabled = True

Any ideas?

Yes you cant call the enabled property until after the Activex Control has been instantiated. Instantiation partly includes setting the OcxState property of the control like...

axWindowsMediaPlayer1.OcxState = ((System.Windows.Forms.AxHost.State)(res.GetObject("axWindowsMediaPlayer1.OcxState")));

(sorry for the c# code)

Again, you need to set the OcxState property of the Activex control during the instantiation of the control. This is done automatically for you if you first add the mediaplayer control to the visual studio tool box then draw the contol onto the screen. You will notice that visual studio adds the code to the initializecomponent() method of the form.

Im guessing that you tried to just instantiate an instance of the player object yourself without using the toolbox?
 
Back
Top