Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I can't seem to make MediaPlayer play a sound!!!!

Status
Not open for further replies.

pmhs

Programmer
Jun 23, 2002
12
PT
Hi! I'm a newbie here, so I really don't know how these forums work, but I have this problem that I wish you could help me solve.
I'm trying to insert sounds in a program for my college course. The program basically allows the user to search a database and add, remove & edit records from the database. It is a very simple program, but I would like to insert some sounds to give it a multimedia touch (and get a better classification from the professor also!), so I inserted the windows media player class in projects>components menu. Then I inserted a media player object in the form, putting the visible property to false.
Next, I call the open method telling him the path of the file to play. Next, I call the play method and he plays the sound in run time but terminates the program and gives me the following message:

Run-time error '-2147467259 (80004005)':
Method 'Play' of object 'IMediaPlayer2' failed

I can't seem to work this one out. Can somebody help me?
Here is the code I've wrote:

Private Sub Form_Load()

frmSplash.cmdSair.Visible = False
frmSplash.Show vbModeless
frmSplash.Refresh
frmSplash.mplSplash.Open "C:\bark.wav"
frmSplash.mplSplash.Play
 
Hi,

Make it like this instead

Private Sub Form_Load()

frmSplash.cmdSair.Visible = False
frmSplash.Show vbModeless
frmSplash.Refresh
frmSplash.mplSplash.Play "C:\bark.wav"


now it should work.
You can use the play function dirrectly instead of the other.
You can also do this


Private Sub Form_Load()

frmSplash.cmdSair.Visible = False
frmSplash.Show vbModeless
frmSplash.Refresh
frmSplash.mplSplash.filename "C:\bark.wav"


Ken Christensen
Ken@Christensen.dk

Ken Christensen software
Support@kc-software.tk
 
it doesn´t work either way!
if I use the play instruction it gives me a message saying:

Wrong Number of Arguments or Invalid Property assignment!

if I use the filename instruction it says:

Invalid use of property!

What I'm I doing wrong?
 
if I use the play instruction it gives me a message saying:

Wrong Number of Arguments or Invalid Property assignment!

if I use the filename instruction it works just fine!
thankx!!!!!!!!!!
mail me if you need anything, ok?
 
Media player has events that you must wait for before calling the Play method. I think you are getting the error cos you are calling the play method before the file has been fully loaded into the player.

Look for the MediaPlayer_OpenStateChange event and put your play code in their.
 
I get small memory leaks when I play files repetitivly with MCI. It happens after I have replayed the same file about 5 times in quick succession (about 2k each time)
Any ideas?
 
I think you also have to specify what sort of file.
="WaveAudio"
Look in the MSDN example
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top