the easiest ways to play an audio clip are the discouraged ones
Jeremy Wood
mickleness at gmail.com
Mon Jan 1 20:28:46 UTC 2024
I agree playing audio was difficult to navigate when I first tried it.
I’m a relative outsider to this group and have no sway over things like
documentation, but for anyone interested in doing their own legwork on
this topic: here’s some code I used to help manage audio:
The audio player itself:
https://github.com/mickleness/pumpernickel/blob/master/src/main/java/com/pump/audio/AudioPlayer.java
A Swing component to help manage it:
https://github.com/mickleness/pumpernickel/blob/master/src/main/java/com/pump/swing/AudioPlayerComponent.java
A jar that executes it:
https://github.com/mickleness/pumpernickel/tree/master/release/jars
A video of the Swing code in action that demos a couple different UIs:
https://screenpal.com/watch/cZVVYZVHymx
- Jeremy
------ Original Message ------
>From mark.yagnatinsky at barclays.com
To swinxythecat at gmail.com
Cc client-libs-dev at openjdk.org
Date 12/31/23, 2:43:09 PM
Subject RE: the easiest ways to play an audio clip are the discouraged
ones
>Resending; last one got blocked due to message size so trimming
>previous conversation
>
>
>
>From: Yagnatinsky, Mark : Markets Pre Trade
>Sent: Tuesday, December 26, 2023 12:18 AM
>To: 'SWinxy' <swinxythecat at gmail.com>
>Cc:client-libs-dev at openjdk.org
>Subject: RE: the easiest ways to play an audio clip are the discouraged
>ones
>
>
>
>Thanks for responding. And thanks for the history page!!
>
>The sad thing is that the issue is not just a documentation issue.
>
>It really does takes around five dozen of lines of code to do
>accomplish the following task:
>
>“play a sound file on my disk without leaking any resources”
>
>(Or at least, I haven’t found a way to do it in much less than five
>dozen lines.)
>
>
>
>AudioAction is also “intern-ish”: it seems designed to be called from
>look & feel code.
>
>
>
>As for the tutorials: I realize they are barely maintained and I wish
>they still were.
>
>But I see they still get occasional updates. Maybe this one could be
>improved.
>
>I suspect the sound tutorial has had no big updates since 1998, though
>the history page you linked claims 2006 for Java 6… (but where’s
>getClip() then?)
>
>
>
>But lack of good docs is merely the second-biggest problem.
>
>The biggest is that the API provides no easy way to accomplish what
>should be a trivial task.
>
>Ideally the following lines of code should Just Work:
>
>javax.sound.Player.playAsync(url); // fire and forget; leaks nothing
>
>javax.sound.Player.playAndWait(url); // returns once playback is done,
>leaks nothing.
>
>I shouldn’t have to know about ULAW vs ALAW vs PCM.
>
>I shouldn’t even have to know about sampled vs midi.
>
>(For nontrivial things, obviously those are very different; but not for
>something this simple.)
>
>I shouldn’t have to implement line listeners and create a countdown
>latch.
>
>It really shouldn’t be this hard!
>
>The current difficulty level is high enough that people will ask
>themselves:
>
>“do I really need add sound support? Maybe I can live without it?”
>
>It should be easy enough that you can do it on a whim!
>
>This message is for information purposes only. It is not a
>recommendation, advice, offer or solicitation to buy or sell a product
>or service, nor an official confirmation of any transaction. It is
>directed at persons who are professionals and is intended for the
>recipient(s) only. It is not directed at retail customers. This message
>is subject to the terms at:
>https://www.cib.barclays/disclosures/web-and-email-disclaimer.html.
>
>For important disclosures, please see:
>https://www.cib.barclays/disclosures/sales-and-trading-disclaimer.html
>regarding marketing commentary from Barclays Sales and/or Trading
>desks, who are active market participants;
>https://www.cib.barclays/disclosures/barclays-global-markets-disclosures.html
>regarding our standard terms for Barclays Corporate and Investment Bank
>where we trade with you in principal-to-principal wholesale markets
>transactions; and in respect to Barclays Research, including
>disclosures relating to specific issuers, see:
>http://publicresearch.barclays.com.
>__________________________________________________________________________________
>If you are incorporated or operating in Australia, read these important
>disclosures:
>https://www.cib.barclays/disclosures/important-disclosures-asia-pacific.html.
>__________________________________________________________________________________
>For more details about how we use personal information, see our privacy
>notice:
>https://www.cib.barclays/disclosures/personal-information-use.html.
>__________________________________________________________________________________
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/client-libs-dev/attachments/20240101/c9e34b29/attachment-0001.htm>
More information about the client-libs-dev
mailing list