Playing Audio from VBScript

This forum is meant for requesting technical support or reporting bugs.

Moderators: time-killer-games, Vengeance66, Candle, reneuend, GM-Support

Playing Audio from VBScript

Postby Skye » Thu Oct 20, 2005 2:39 pm

Prior to the Forum problems there was a post concerning how to play a sound (and how to play a video) using scripting . . . .

<snip>
Sub PlaySound(FileName, Repeat)
Action.LoadControl MediaPlayerObject(2)
MediaPlayerObject(2).FileName = FileName
If Repeat = True Then
MediaPlayerObject(2).PlayCount = 0
Else
MediaPlayerObject(2).PlayCount = 1
End If
MediaPlayerObject(2).Play
End Sub


Is there a particular program or utility that needs to be present on a computer for this subroutine to function properly? I installed a copy of my game on an old laptop and everytime the game came to a location where I had used the subroutine PlaySound the game encountered an error (Automation Error) and the sound would not play.

Do I need to make sure that a Windows Media player is present on the computer to ensure that this scripted 'play sound' option will work?

Thanks,
Skye
Skye
Expert Member
 
Posts: 325
Joined: Sat Sep 13, 2003 4:19 pm
Location: British Columbia, Canada

Postby GM-Support » Thu Oct 20, 2005 7:27 pm

Hi Skye,

Yes, it requires either Windows Media Player (any version above 5) or DirectX (any vesion). Or both of course.

BTW, if it works with non-scripted sounds, it should work with scripted sound as well. Does it work with non-scripted sounds?

GM-Support
GM-Support
Forum Admin and Games Page admin
 
Posts: 2221
Joined: Thu Jun 05, 2003 7:52 pm

Postby Skye » Thu Oct 20, 2005 9:30 pm

Hi GM,

Yes the non-scripted sounds work just fine. It was the ones that I had scripted that seem to be the problem.

I'll have to check and see if my 'test' computer has the media player installed. I have a hunch it may not.

Skye
Skye
Expert Member
 
Posts: 325
Joined: Sat Sep 13, 2003 4:19 pm
Location: British Columbia, Canada

Postby GM-Support » Sun Jan 08, 2006 10:21 pm

The "automation error" was due to the file not being found.

All the details to solve the problem can be found at:
http://www.adventuremaker.com/phpBB2/vi ... php?t=1405

Best regards,
GM-Support
GM-Support
Forum Admin and Games Page admin
 
Posts: 2221
Joined: Thu Jun 05, 2003 7:52 pm

Postby !Jakon » Sun Mar 26, 2006 6:19 am

Yeah, you are right man! :(
God bless America!
!Jakon
New Member
 
Posts: 4
Joined: Sun Mar 26, 2006 6:17 am

Still confused

Postby hegel5000 » Sat Apr 15, 2006 5:39 pm

I didn't start this topic, but I'm still a bit confused as to exactly which code you need to play a sound. In addition, can you control which channel the sound is played in?

` For instance: I want to have a sound file called "bash.wav" played in a timer that already activates a textbox. What should I type?
hegel5000
Member
 
Posts: 40
Joined: Tue Jan 17, 2006 3:44 am
Location: En la casa de la mama grande.

Postby Skye » Mon Apr 17, 2006 4:50 am

Hi Hegel,

You need to include the

Code: Select all
Sub PlaySound(FileName, Repeat)
Action.LoadControl MediaPlayerObject(2)
MediaPlayerObject(2).FileName = FileName
If Repeat = True Then
MediaPlayerObject(2).PlayCount = 0
Else
MediaPlayerObject(2).PlayCount = 1
End If
MediaPlayerObject(2).Play
End Sub


part somewhere in your procedure and then when you want to play the sound, you use this:

Code: Select all
PlaySound GetPath(2) filename.wav, false


The "GetPath(2)" tells the engine to look in the External folder for the wave file. You need to put it there or when the game is compiled, you will get errors.

As far as I know, there isn't any way to tell which channel the sound will come out on.

Hope this helps,
Skye
Skye
Expert Member
 
Posts: 325
Joined: Sat Sep 13, 2003 4:19 pm
Location: British Columbia, Canada

Gracias

Postby hegel5000 » Tue Apr 18, 2006 1:37 am

Thanks so much. WindowShades is gonna feel really EarthBoundy now!
hegel5000
Member
 
Posts: 40
Joined: Tue Jan 17, 2006 3:44 am
Location: En la casa de la mama grande.


Return to Adventure Maker Technical Support and Bug Reports

Who is online

Users browsing this forum: No registered users and 0 guests

cron