Howto: play sound under Linux

Share your scripts and packages with other Mudlet users.
Post Reply
eraldo
Posts: 43
Joined: Sun Jul 12, 2009 1:25 am

Howto: play sound under Linux

Post by eraldo »

Since sound does not yet work with my linux machine (Ubuntu)
I found the following workaround to do the job:

Code: Select all

AvalonPath = "/home/eraldo/reference/Avalon/"
SoundPath = AvalonPath .. "sounds/"

function playSound( sound )
    os.execute( "mplayer " .. SoundPath .. sound )
end
now you can play a sound like this:

Code: Select all

playSound( "sound.wav" )
This only works assuming you have mplayer
and the file "sound.wav" under "/home/eraldo/reference/Avalon/sounds/"
> Adjust both (path and player) according to your needs.

eraldo
Posts: 43
Joined: Sun Jul 12, 2009 1:25 am

Re: Howto: play sound under Linux

Post by eraldo »

Problem: The input is blocked until the sound has finished playing.
(Thus I use it only if I am away)

But hey, that's better than nothing. :D

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Howto: play sound under Linux

Post by Heiko »

Use artsplay (kde) instead of mplayer or a similar sound play program for gnome.
e. g.:

Code: Select all

AvalonPath = "/home/eraldo/reference/Avalon/"
SoundPath = AvalonPath .. "sounds/"

function playSound( sound )
    os.execute( "artsplay " .. SoundPath .. sound )
end
This command will return immediately and there will be no lock up and you can play sounds simultaneously.
Mplayer, xine etc. would need to be started as a new process e.g.
mplayer mysound.wav &
xine mysound.wav &
As these programs are usually not intended to be used this way you'd probably need to set some special options to hide the gui etc.

I'll add the dependencies to play sounds on Linux with the built-in Mudlet functionality in the next couple of weeks. It's easier on windows and MAC. On Linux you need some special packages but the above solution is simple and a good workaround.

eraldo
Posts: 43
Joined: Sun Jul 12, 2009 1:25 am

Re: Howto: play sound under Linux

Post by eraldo »

Used Audacious...
works great!
Thank you!

Zenock
Posts: 10
Joined: Thu Feb 03, 2011 11:00 pm

Re: Howto: play sound under Linux

Post by Zenock »

I'm on gnome in Ubuntu... apparently artsplay isn't an option or I'm just stupid and can't figure out how to get it installed. Tried audacious, it opens a gui and won't continue until the gui is closed.

I've tried multiple players am having trouble finding one that forks and returns immediately. Any help would be nice.

Zenock
Posts: 10
Joined: Thu Feb 03, 2011 11:00 pm

Re: Howto: play sound under Linux

Post by Zenock »

For anyone who want's to know. In GNOME use esdplay...

Post Reply