Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Playing a sound file  (Read 20424 times)
Tim B.
Posts: 67


« on: May 06, 2009, 02:09:33 pm »

Is it possible to get the GDC to play a sound by using the a Frontcall to the winmm library (sndPlaySoundA function I believe)?  I've tried and not had much success.  If I use the wrong library or function name it errors accordingly, but if I use

CALL ui.Interface.frontcall("winmm","sndPlaySoundA",["file.wav",0],[l_res])

it simply crashes the GDC.  Possibly I haven't got the parameters correct, or maybe it's not possible to call such a function directly.
Reuben B.
Four Js
Posts: 1119


« Reply #1 on: May 07, 2009, 06:05:54 am »

Is it possible to get the GDC to play a sound by using the a Frontcall to the winmm library (sndPlaySoundA function I believe)?  I've tried and not had much success.  If I use the wrong library or function name it errors accordingly, but if I use

CALL ui.Interface.frontcall("winmm","sndPlaySoundA",["file.wav",0],[l_res])

it simply crashes the GDC.  Possibly I haven't got the parameters correct, or maybe it's not possible to call such a function directly.

Tim, 

Make sure you have a look at https://4js.com/techdocs/genero/gdc/devel/DocRoot/User/FEExtensions.html on the steps you need to do to make a front-call to a .dll.  I suspect if you are using winmm you'd need to create a wrapper for it.

To play sound, the first thing I'd try is a shellexec frontcall on the .wav file CALL ui.Interface.FrontCall("standard","shellexec","file.wav",result), or an execute frontcall using sndrec32 and the .wav file.  However from what I could google sndrec32 isn't available on Vista and there didn't seem to be a better alternative.  Last time I tried I could play sound but hadn't figured a way to stop Windows Media Player becoming visible.

Also if you are interested have a look at the voice example I put here http://code.google.com/p/sourcefourjs/downloads/list that hooks into the Microsoft Agents.


Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Tim B.
Posts: 67


« Reply #2 on: May 07, 2009, 10:01:49 am »

I have looked at that document, which is how I arrived at the syntax I have.  Unfortunately is doesn't seem to work.

I have already written a VB app which calls this function of winmm and plays sounds 'invisibly'.  This works fine, but relies on that program being installed on the remote PC.  What I was hoping to do is to cut out reliance on this app and call the function directly.  From the look of it it should be possible, but I just can't get it to work.  Possibly it needs a wrapper, in which case I'll just stick to chat I have got already.

Using shellexec of sndrec32 will cause the player to become visible (and media player is way too bulky) , which isn't practical on the type of production system we are running.
Paul S.
Posts: 45


« Reply #3 on: May 07, 2009, 12:45:31 pm »

Try:

CALL ui.Interface.frontcall("standard","playsound",filename,anything)

filename is a STRING containing the location of the wav file eg: \\ANYSYSTEM\sounds\startup.wav

This is unsupported and undocumented, but works for me on XP client.

Paul
Tim B.
Posts: 67


« Reply #4 on: May 07, 2009, 01:39:46 pm »

Thanks - that works.  I had a feeling that there was a built in function somewhere.  It was maybe mentioned by someone at some point or other.

The question is:- will this be supported or is it experimental, and can it be relied upon in future versions?
Paul S.
Posts: 45


« Reply #5 on: May 08, 2009, 11:11:09 am »

The question is:- will this be supported or is it experimental, and can it be relied upon in future versions?

This is a good question, hopefully someone from FourJ's will answer for the both of us.

Paul
.
Four Js
Posts: 115


« Reply #6 on: May 11, 2009, 09:41:39 am »

Hello,

this is in GDC for a long time and it won't be removed, but the support is tightly linked to Qt support.
The main issue is this is using an old function which relies on basic system calls, and is therefore very limited.

From Qt's doc:

Quote
Microsoft Windows:
The underlying multimedia system is used; only WAVE format sound files are supported.

X11:
The Network Audio System is used if available, otherwise all operations work silently. NAS supports WAVE and AU files.

Mac OS X:
NSSound is used. All formats that NSSound supports, including QuickTime formats, are supported by Qt for Mac OS X.

Qt now offers much more advanced multimedia features, we're looking on how to integrate them in Genero context, so this will replace the simple playsound front call.


Tim B.
Posts: 67


« Reply #7 on: May 11, 2009, 10:14:27 am »

Excellent news.  We can certainly use the playsound functionality for the time being.

It might be worth adding to the docs.  I couldn't find it in there.
Paul S.
Posts: 45


« Reply #8 on: May 11, 2009, 10:35:15 am »

Thanks for the response.

That is fine.

Paul
Reuben B.
Four Js
Posts: 1119


« Reply #9 on: May 11, 2009, 11:06:02 am »

Hello,

this is in GDC for a long time and it won't be removed, but the support is tightly linked to Qt support.
The main issue is this is using an old function which relies on basic system calls, and is therefore very limited.

From Qt's doc:

Quote
Microsoft Windows:
The underlying multimedia system is used; only WAVE format sound files are supported.

X11:
The Network Audio System is used if available, otherwise all operations work silently. NAS supports WAVE and AU files.

Mac OS X:
NSSound is used. All formats that NSSound supports, including QuickTime formats, are supported by Qt for Mac OS X.

Qt now offers much more advanced multimedia features, we're looking on how to integrate them in Genero context, so this will replace the simple playsound front call.




Hi Pierre-Nicolas,

Is it worth documenting this functionality in the experimental features section of the GDC docs?

Reuben

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines