At 06:21 AM 8/25/2011 -0700, G Gambill wrote:
>I am looking for hints as to how (if possible) to inbed audio files within a
>dbf (dbc) and play the via a VFP exe.
>
>Any suggestion?
>
>Thanks
>
>George
You can read the audio file from disk into a "string" (e.g. FILETOSTR()).
Then store it in your table in a Memo field (I'd recommend a "Memo
(binary)" field). Definitely do not use General (at least IMO).
Then when you need it, save the data back to disk (e.g. STRTOFILE()) and
call whatever API or such to play that file.
Your table could have an additional field to hold a designator or ID so you
could set up a general method to call to look for a sound and play it. E.g.
something like the following:
*-- Method: playmysound
*-- Parameters:
*-- - cSound2Get: the 'string' to look for in the <soundtable>
*-- Assumptions
*-- - the <soundtable> table has a memo field storing the sound
*-- - <soundtable> has an index called "SOUNDITEM" (e.g. index on a char
field)
*-- Notes:
*-- - as with any "string" index, you'll have to make sure the string
passed is
*-- the right length to match the index
*--
PARAMETERS cSound2Get
LOCAL cTempSoundFile
*-- you should know where you can create files, etc. so I alway put the full
*-- path name on the files I create so I'm sure where they're going.
cTempSoundFile = <make a temp name in a place you know you can>
cSound2Get = padr(cSound2Get, 20, " ")
IF SEEK(cSound2Get, <NameofSoundTable>, "SOUNDITEM")
STRTOFILE(<nameofsoundtable>.<nameofmemofield>, cTempSoundFile)
ELSE
*-- you might have a "default" sound to play, or you could just ignore
=SEEK(PADR("DEFAULT",20," "), <NameofSoundTable>, "SOUNDITEM")
STRTOFILE(<nameofsoundtable>.<nameofmemofield>, cTempSoundFile)
ENDIF
*-- "play" the file
<there is a winapi to play sounds, or maybe you have some other option you
want to use - call it here with the filename you created>
<Note: if you're playing long-running files, you probably shouldn't try to
delete it at the end of this routine. The APIs I use fire off the playing
and let my app continue on executing. So the file would likely still be in
use at this point. If you know you have just a couple seconds of sound, you
could put a SLEEP() step here (windows api) if you don't mind having the
whole app on hold until the sound finishes.>
RETURN .T.
Of course, you could do the above with a
SELECT...... FROM <cSoundTable> WHERE....
But I like to use SEEK() since that means you only have to "move" the data
once. A SELECT would move the sound file from the table, into temp memory
(e.g. a cursor) and then you'd have to write it out to disk. With the SEEK
you just are moving it straight from the table to disk.
Note: the above is not tested and there are a lot of little things you'd
want to fill in, check, etc.
HTH,
-Charlie
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.