Home » Developing U++ » U++ Developers corner » Sound in linux (Lack of standards in Linux is a problem but there are some near-standards)
Re: Sound in linux [message #44096 is a reply to message #44094] |
Wed, 24 December 2014 13:18 |
|
Klugier
Messages: 1076 Registered: September 2012 Location: Poland, Kraków
|
Senior Contributor |
|
|
Hello Mirek,
The detection can be done in following way:
// Copy from PrinterJob.cpp -> I think it should be part of POSIX U++ library!!!
static String System(const char *cmd, const String& in)
{
String ofn = GetTempFileName();
String ifn = GetTempFileName();
SaveFile(ifn, in);
String c = cmd;
c << " >" << ofn;
if(in.GetCount())
c << " <" << ifn;
String q;
if(system(c) >= 0)
q = LoadFile(ofn);
FileDelete(ofn);
FileDelete(ifn);
return q;
}
static String FindPlayer()
{
static String player;
if (player.IsEmpty()) {
const char *players[] = { "play", "ogg123" }; // <- Add all possible players here!!!
for (int i = 0; i < __countof(players); i++) {
if (!System("which " + String(players[i]), Null).IsEmpty()) {
player = players[i];
break;
}
}
}
return player;
}
static void LinuxBeep(const char *name)
{
String player = FindPlayer();
if (!player.IsEmpty()) {
String fn = "/usr/share/sounds/" + CurrentSoundTheme + "/stereo/dialog-" + name;
system(player + " -q " + fn + (FileExists(fn + ".ogg") ? ".ogg" :
FileExists(fn + ".oga") ? ".oga" :
FileExists(fn + ".wav") ? ".wav" :
".*")
+ " >/dev/null 2>/dev/null&");
}
}
IMO, There is a problem that function "System" is not part of U++ (I don't want to do copy&past). Can we do something with that issue?
Sincerely,
Klugier
-
Attachment: Sound.diff
(Size: 1.79KB, Downloaded 231 times)
U++ - one framework to rule them all.
[Updated on: Wed, 24 December 2014 13:21] Report message to a moderator
|
|
|
|
|
Sound in linux
|
|
|
Re: Sound in linux
By: mirek on Wed, 17 December 2014 11:30
|
|
|
Re: Sound in linux
|
|
|
Re: Sound in linux
By: mirek on Wed, 17 December 2014 19:56
|
|
|
Re: Sound in linux (& generic launchers)
|
|
|
Re: Sound in linux (& generic launchers)
|
|
|
Re: Sound in linux
|
|
|
Re: Sound in linux
|
|
|
Re: Sound in linux
|
|
|
Re: Sound in linux
|
|
|
Re: Sound in linux
|
|
|
Re: Sound in linux
|
|
|
Re: Sound in linux
By: Klugier on Tue, 23 December 2014 14:49
|
|
|
Re: Sound in linux
|
|
|
Re: Sound in linux
By: mirek on Wed, 24 December 2014 12:27
|
|
|
Re: Sound in linux
By: Klugier on Wed, 24 December 2014 13:18
|
|
|
Re: Sound in linux
By: mirek on Wed, 24 December 2014 15:46
|
|
|
Re: Sound in linux
By: Klugier on Wed, 24 December 2014 16:30
|
|
|
Re: Sound in linux
By: mirek on Thu, 25 December 2014 10:48
|
|
|
Re: Sound in linux
By: Klugier on Thu, 25 December 2014 13:56
|
|
|
Re: Sound in linux
By: mirek on Thu, 25 December 2014 21:01
|
|
|
Re: Sound in linux
|
|
|
Re: Sound in linux
By: Klugier on Thu, 25 December 2014 14:23
|
Goto Forum:
Current Time: Sat May 11 06:09:45 CEST 2024
Total time taken to generate the page: 0.01991 seconds
|