Home > Archive > Getting Started with dBASE > November 2006 > Play Sound Command









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Play Sound Command
Rachhpal

2006-11-03, 12:12 am

Play Sound Filename <name.wav>
works fine when you run the programm. But when you use in project
application, you hear no sound.
Rick Miller

2006-11-03, 7:12 pm

Rachhpal <rachhpalg@yahoo.com> wrote in news:lb8EhTv$GHA.1780@news-
server:

> Play Sound Filename <name.wav>
> works fine when you run the programm. But when you use in project
> application, you hear no sound.

----

May need to specify the fullpath\filename.wav
in the code or could use a sounds sub-folder
for wav files used by the application.

playSound("save.wav")


function playSound(cFile)
Local cWav
if cFile.indexOf("\") == -1
// use wav file from the application sounds folder.
cWav = set("directory") + "\sounds\" + cFile
else
cWav = "" + cFile
endif
play sound filename (cWav)
return

Hope it helps,
Rick Miller
Rachhpal

2006-11-05, 7:14 pm

As suggested by Rick I specified the full path, it did't work.

I tried playing binary filed. It will work when you run the programm, still problem with runtime only sound you hear is little click.

Thanks for help


Rick Miller Wrote:

> Rachhpal <rachhpalg@yahoo.com> wrote in news:lb8EhTv$GHA.1780@news-
> server:
>
> ----
>
> May need to specify the fullpath\filename.wav
> in the code or could use a sounds sub-folder
> for wav files used by the application.
>
> playSound("save.wav")
>
>
> function playSound(cFile)
> Local cWav
> if cFile.indexOf("\") == -1
> // use wav file from the application sounds folder.
> cWav = set("directory") + "\sounds\" + cFile
> else
> cWav = "" + cFile
> endif
> play sound filename (cWav)
> return
>
> Hope it helps,
> Rick Miller


Marty Kay

2006-11-07, 7:13 pm

> Play Sound Filename <name.wav>
> works fine when you run the programm. But when you use in project
> application, you hear no sound.


When dBASE calls windows to play a sound, it passes a parameter telling
Windows to play
the sound asynchronously, i.e., to setup to play the sound and then return
from the function immediately.
When running the command: PLAY SOUND FILENAME <your sound file>
- the sound will play completely in the dBASE IDE because the user has not
closed down dBASE before the sound has a chance to play.
- when run using the dBASE runtime, the runtime has no other code to run
and no form to display, so it exits immediately - before Windows has time to
play very much of the sound.

If you create a form and run the sound from a form event or from a button on
the form, the runtime will not shut down and the complete sound will play.
- Marty Kay (dBI) -


Rick Miller

2006-11-07, 7:13 pm

/*
Sorry, no other ideas ;-(

What version of dBASE r u using ?

Below, is a sample form for playing wav files.
It should work in both the IDE and runtime.

Rick Miller
*/

** END HEADER -- do not remove this line
//
// Generated on 11/07/2006
//
parameter bModal
local f
f = new playsoundForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif

class playsoundForm of FORM
with (this)
metric = 6 // Pixels
height = 117.0
left = 0.0
top = 0.0
width = 476.0
text = " Play a Sound (wav file)"
icon = "resource #93"
endwith

this.TXFILENAME = new TEXT(this)
with (this.TXFILENAME)
height = 44.0
left = 0.0
top = 0.0
width = 476.0
anchor = 2 // Top
alignVertical = 1 // Middle
alignHorizontal = 1 // Center
text = ""
endwith

this.PBSELECT = new PUSHBUTTON(this)
with (this.PBSELECT)
onClick = class::PBSELECT_ONCL
ICK
height = 24.0
left = 7.0
top = 55.0
width = 210.0
text = "Select File to Play"
endwith

this.PBPLAY = new PUSHBUTTON(this)
with (this.PBPLAY)
onClick = class::PBPLAY_ONCLIC
K
height = 24.0
left = 259.0
top = 55.0
width = 210.0
text = "Play Sound"
endwith


//------------------------------------------------------------//
function pbPlay_onClick
Local cFile
cFile = "" + form.txfilename.text
if empty(cFile)
msgbox("Select a File to Play", "Not ready", 48)
form.pbSelect.setFocus()
else
play sound filename (cFile)
endif
return

//------------------------------------------------------------//
function pbSelect_onClick
Local cDir, cFile
if empty(form.txFilename.text)
cDir = set("directory")
else
cDir = form.txFilename.text.left( ;
form.txFilename.text.lastIndexOf("\"))
endif
cFile = getFile(cDir + "\*.wav", "Select a Wav file")
if not empty(cFile)
form.txFilename.text := cFile
endif
return

endclass

Bowen Moursund [DataTech]

2006-11-07, 7:13 pm

Perhaps you can make use of the attached class.


--
Bowen Moursund
DataTech
Consulting & Development
http://www.bmmnet.us

Marty Kay

2006-11-07, 7:13 pm

> Perhaps you can make use of the attached class.

Thanks Bowen,

Very nice.

- Marty Kay (dBI) -


Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com