[R-SIG-Mac] sound::setWavPlayer()

Hans-Jörg Bibiko bibiko at eva.mpg.de
Thu Aug 28 09:04:58 CEST 2008


On 27.08.2008, at 17:21, Hans-Jörg Bibiko wrote:

> On 27.08.2008, at 17:06, Simon Urbanek wrote:
>
>> To be precise to play an audio file all you do is
>> [[[NSSound initWithContentsOfFile:fileName byReference:YES]  
>> autorelease] play];
>> Thats' all :)
>
> Ah, you mean that the function play(A_SOUND_FILE) should be part of  
> R's core code which implements it for a given platform.
> This of course would be the best way.

I thought about it a bit. For Mac it would be trivial, but for Windows  
and Linux I do not know. They have to support many sound card drivers.  
For Linux you have different window servers, and distributions.
The next point once you have such a built-in function like  
playSoundFile(f) how to control it, i.e how to stop it for instance;  
esp. for the case that you're playing more than one sound file at a  
time (which works a Mac with play very well).

To use the approach to open a sound file by the default application is  
in some sense better. On Mac it's easy, just type 'open FILE', for  
Windows this works only in some cases. One could use 'start FILE' but  
'start' is not an executable it's a DOS command thus one could write a  
BAT file open.BAT à la 'start %1'. The tricky point is Linux in that  
respect I believe. I do not know any command which can do this. The  
Linux shell command 'play' is not part of any distribution.
This leads to a next problem. If there would be a general solution to  
play a sound file using the default app OK but if the user can set up  
the player to 'mplayer32.exe', or 'play' etc. how to distinguish  
between a shell command, which could run in the background (how to  
control it?), and a app based program like 'Windows Media Player' or  
'QuickTime' etc.?


The only idea I have for now is to use a scripting language to write a  
primitive audio player, and the only language which is installed by  
default on all these platforms is Java. It shouldn't be that problem  
to write such a JFrame jar.

Cheers,

--Hans



More information about the R-SIG-Mac mailing list