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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I play a WAV file included in project 1

Status
Not open for further replies.

GriffMG

Programmer
Mar 4, 2002
6,343
FR
I'm sure this has been asked before but I can't find it!

I have a .wav file included in my project (and hopefully in my resultant .exe) and I want to access to set my 'bell' to it:

Code:
set bell to 'mysound.wav'
?? chr(7)
set bell to

What do I need to do the the 'Set Bell to ...' line to
get VFP to read the internal .wav file?

I'm running this in VFP 6

Regards

Griff
Keep [Smile]ing
 
While I was waiting...

I've found a 'cheats way' - I added a free table to the project, then included it in the executable. I gave the table one field called sound as a binary memo - then append a record and replaced the memo field with a filetostr() of my wav file.

When I run the app on the remote machine - I get the code to look for the wav file in the applications folder and if it isn't there, extract it from the binary memo field:

Code:
select 0
Use ("c:\myoriginaldevfolder\sound")
strtofile(whereami+"mywav.wav")
use
set bell to (whereami+"mywav.wav")
?? chr(7)

But is this the best way?
I wonder if it might be a good way of distributing other binary files in a single executable - without using a set-up package?

tia

Regards

Griff
Keep [Smile]ing
 
Hi Griff,

As far as I can see, your original code looks OK. Have you tried running it? Provided the WAV is in the project when you run the build, and you haven't flagged it as excluded, the run-time code should find it.

For a completely different approach, you could use ShellExecute() to play the WAV -- see for more info. But your original idea of using SET BELL is simpler.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Hi Mike,

Yeah, I did try running it - just tried again - and the original idea doesn't work in code. My 'plan b' works well enough - but looks a little clumsy!

Mind you, I'm thinking it might be a usefull way of putting a binary file of any kind on the remote machines hard disk.

Funny that VFP is happy for you to access tables as so forth 'embedded' in the application - but not quite so happy with .wav files!

Thanks Mike




Regards

Griff
Keep [Smile]ing
 
As long as the OS can find the wav file; be it in a path statement or registered as a default sound, you should be able to use your original code:

SET BELL TO "somefile.wav"
?CHR(7)

I tried it using:
SET BELL TO "C:\temp\dave.wav"
?CHR(7)

And it worked fine by copying the wav file to the temp directory.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Hi Dave,

The thing I'm trying to resolve is accessing the wav file while it's still INSIDE the executable (if you follow me) as an included file in the project (like the forms, text files, bit maps etc).

I don't seem to be able to do that.

Any ideas - is this an option I need to turn on?


Regards

Griff
Keep [Smile]ing
 
Griff,

In general, VFP will find a file embedded in an EXE. I don't know if there's anything unusual about a WAV file, or if it is the SET BELL that is causing the problem.

Still, your solution looks like a good workaround.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Hi Mike,

I think, stress think, that VFP can only access certain file types in this way - not that it's a bug, just how it is.

I am going to use my technique and adopt it for any binary I want distributed with an app from now on.

Thanks all fro their thoughts.

Martin

Regards

Griff
Keep [Smile]ing
 
Griff,

...still INSIDE the executable (if you follow me)...

I follow you now, but it went right over my head the first time. [blush]
I have had issues with other binary files embedded in the executable before, so i tend to not trust it. It's possible a .wav file would behave the saem way. I prefer to all binary files as not included any more.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Thanks Dave

I think the approach I dreamt up is ok.

Any other route would indeed be unreliable.

Ta for your help



Regards

Griff
Keep [Smile]ing
 
Griff,

One method I've used is to change the file extension of the "included" file and then copying the file to the local drive the first time it's needed. So in my project I'd have mywave.vaw (the 'wav' backwards), and if I couldn't find 'mywave.wav' I'd COPY FILE MYWAVE.VAW TO MYWAVE.WAV and then do ? CHR(7).

Steve
 
Hi Steve,

That probably works well.

I'm using my approach for loads of stuff now though! I am able to distribute any binary I like now, so I can put all kinds of little executables in the actual program and only have to send out one file! No messages about overwrite two or more files...

Amazing how a problem can become a solution!

Many thanks

Martin

Regards

Griff
Keep [Smile]ing
 
Thank you Stella740pl!

Regards

Griff
Keep [Smile]ing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top