play wav (or any audio file, if possible)

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
PepsiHog
Automation Wizard
Posts: 511
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

play wav (or any audio file, if possible)

Post by PepsiHog » Tue Aug 11, 2009 12:06 am

I am writing a program where I need to be able to play a wav and while it is playing I need to be able to issue a command or click a button in a menu that will stop the play back. (instantly)

I say play a wav, but really I just need to play an audio file. the type doesn't so much matter. ( wav, mp3....whatever) But the key is I need to be able to stop it with a command line or by clicking a given button in a menu. I would prefer the button option.

Does anyone have a script that will do this, that I could use in my script?
I figure if I knew VBS I could do this a lot easier, but I don't. (YET)
Maybe you have the skill to do this. Will you share with me?

Or second, less preferred but will settle, for a dos base exe with command line parameters. As long as it meets the instant stop requirement. If anyone knows of such a program, will you please let me know. My script would have to be able to control this external exe.

I am using Windows XP

You may respond through this post. Or you may send it by e-mail.

And Thank very much!
[email protected]
......and that is not a typo.

Brian A.K.A PepsiHog
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2021) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Aug 11, 2009 8:07 am

Why not:

Using the built-in PlayWav command make a simple one line macro that looks like this:

PlayWav>yourwavfile.wav

Actually you might want it in a loop so it plays continuously:

Label>start
PlayWav>your.wav
Goto>start

Compile this to a .EXE

Have your main macro asychronously run this .EXE with a simple Run command (without RP_WAIT) when the wav file should start.

When your main macro needs to stop the wav file simply kill the .EXE process using the KillProcess function found here:
http://www.mjtnet.com/forum/viewtopic.php?t=1779

HTH
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Aug 11, 2009 11:58 pm

Also see this link: http://www.microsoft.com/technet/script ... y1103.mspx about using Windows Sound Recorder from the command line. Example of how to play and close files. Samples using scripts but I think you could use Macro Scheduler RunProgram> command instead.

I have not tested this, just tossing you an idea......
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
PepsiHog
Automation Wizard
Posts: 511
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

need to play a wav......Thanks

Post by PepsiHog » Fri Aug 14, 2009 7:57 pm

Thanks guys!

I really appreciate your help. Good ideas, I will give them a try!

PepsiHog 8)

p.s.
Have your main macro asychronously run - is that a complicated way of saying run both at the same time or is there a process?
Is that running one macro from another?
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2021) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: need to play a wav......Thanks

Post by Marcus Tettmar » Mon Aug 17, 2009 8:00 am

PepsiHog wrote:
Have your main macro asychronously run - is that a complicated way of saying run both at the same time or is there a process?
Is that running one macro from another?
Asynchronous means we don't wait for the other process to finish. Synchronous means we do. RunProgram by default is asynchronous. It STARTS the other program and the script continues, not waiting for that program to complete. RunProgram with RP_WAIT set to 1 is synchronous - it starts the program and waits until it has terminated before the script continues. So what I mean is if you start your second macro .exe with RunProgram in default mode (without RP_WAIT=1) then both macros would then be running AT THE SAME TIME as the calling macro continues on. Make sense?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts