PDA

View Full Version : Play wav file on exit


DaystromM5
01-30-2006, 09:09 PM
I have an AMS5 project that I'm trying to update. Since i don't have the am5 file anymore, I believe I have to start from scratch.

I am trying to play a wav file before exiting the app when clicking the exit button. How do I script it so the wav file plays completely before exiting?

I've tried these on the On Click event for the exit button

Audio.Load(CHANNEL_USER1, "AutoPlay\\Audio\\TCmdD238.wav", true, false);
Application.Exit(0);

This starts the wav file, but exits before it is finished

And

Audio.Load(CHANNEL_USER1, "AutoPlay\\Audio\\TCmdD238.wav", true, false);
length = Audio.GetLength(CHANNEL_USER1);
repeat
position = Audio.GetCurrentPos(CHANNEL_USER1);
until position == length;
Application.Exit(0);

This plays the wav file, but then the application hangs and never exits.

I'd like to know what I'm doing wrong. I'm betting it's somewhere close to everything.

rhosk
01-31-2006, 05:35 AM
Use an invisible WMP plugin - put an Application.Exit() on the 'On Finish' event.

Load the wav file at runtime. On your exit button -

MediaPlayer.Play("Plugin1");

One of many ways to do it, HTH.

TJ_Tigger
01-31-2006, 08:49 AM
Ron, this seems like deja vu.

A solution I suggested in another thread was to load and play the song and set a variable (bExit) to true. Then in the On Audio for the page on the Finish state for the audio if bExit is true then exit the application.

Tigg

Gabis
01-31-2006, 02:36 PM
would using Application.Sleep(songs length) work? or would that pause the wav file?

rhosk
01-31-2006, 03:13 PM
would using Application.Sleep(songs length) work? or would that pause the wav file?
Actually, that does work :yes who would've thought?
Good one Gabis! Sometimes the solutions can be really simple.

DaystromM5
01-31-2006, 06:34 PM
Thanks Gabis, and the rest of you for your help. The Application.Sleep command worked perfectly. I had a few other problems the first time I made this, and I'm sure I'll be back for more help

Thanks Again

pjborg
02-01-2006, 01:33 AM
I've tried the "sleep" method before, but I think the On Audio - On Finish gives you more control, as Tigger suggests. You would want to trim any silence from the end of the audio file. PJ