which exec() a system tool for playing sounds (afplay, on the Mac). But that's quite clumsy, system-dependent,

Unfortunately, any solution that runs an external command will most likely be system-dependent. Even without looking at Audio::Play::MPG123, I strongly suspect based on the error message that it's also just trying to run an external command. Update: After having looked into this a little more, let me rewrite that paragraph. Calling an external program of course feels a little clunky and inelegant, but at the moment I am not aware of cross-platform Perl modules for playing audio that don't make use of any external tools (perhaps I've just overlooked them, if someone else knows of one, please share - Update 3: see Discipulus's and zentara's comments about SDL here). So perhaps calling an external program is not such a bad choice, if you can run it in the background and control its execution. Audio::Play::MPG123 uses mpg123, which like SoX below also says it is cross-platform, so perhaps you just don't have it installed (Update 2: as 1nickt also pointed out in the meantime). Instead of that module, you can also use the solution I linked to below.

Perhaps this will help in being a small piece in your puzzle: I showed some working code how to run a program that plays a sound while your script keeps running, and how to interrupt playback, using IPC::Run at Re^5: Killing a child process (the rest of the thread may be an interesting read too). The script uses the play tool from SoX, which according to its website is available for *NIX including Mac OS X, as well as Windows.


In reply to Re: Playing sounds (updated) by haukex
in thread Playing sounds by Chuma

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.