I wrote the following code that works fine. But I think it only works with .wav
format.
public static synchronized void playSound(final String url) { new Thread(new Runnable() { // The wrapper thread is unnecessary, unless it blocks on the // Clip finishing; see comments. public void run() { try { Clip clip = AudioSystem.getClip(); AudioInputStream inputStream = AudioSystem.getAudioInputStream( Main.class.getResourceAsStream("/path/to/sounds/" + url)); clip.open(inputStream); clip.start(); } catch (Exception e) { System.err.println(e.getMessage()); } } }).start(); }
Related Posts:
- Where can i get BigClip? [closed]
- Difference between mimetypes: audio/mpeg and audio/x-mpeg
- Playing mp3 song on python
- compressed and uncompressed .wav files
- How to add a new audio (not mixing) into a video using ffmpeg?
- Playing .mp3 and .wav in Java?
- How do I make JavaScript beep?
- Making audio playlist with external audio files?
- How to get the number of times an audio file has been played
- Download button for wp audio player
- Is it possible to control the width of the WordPress audio player?
- How to add audio files to wordpress blog and making it auto play?
- Background audio player
- How to make WordPress audio playlist understand the direct links of audio files shared on google drive?
- Removing Theme Audio Player – Using Browser Default
- Audio preloading
- Adding a download link to native WordPress playlist
- Using track metadata from audio shortcode
- Is ‘preload=”none”‘ a valid parameter in the [audio] shortcode in WordPress 3.6?
- wp_audio_shortcode shows player and url [closed]
- Starting from what version WordPress provides own embedded audio player without need a plugin?
- WordPress Audio tag problem in Chrome
- Change audio player style
- How to get the number of times an audio file has been played
- Trim Audio Files [closed]
- Convert mp3 into ogg?
- Is the .flac audio file format supported by WordPress?
- audio link produces black box
- Need to hide/remove volume bar in WordPress Default Player to give more room to progress bar
- Clicking “Download MP3” downloads 0kb file
- Show audio player only in specific post type
- Trying to get the number of times an audio file has been played
- How to disable theme’s player styles so I could use plugin player?
- WP audio playlist width
- WordPress default audio playlist – how to add custom caption?
- How to restore deleted audio files from media library
- WordPress Audio Player
- Number of times an audio file has been played using custom player
- Trying to turn all of my posts into a soundcloud playlist and can’t figure out where to start
- Open template file in Pop Up
- MediaElement audio tag not visible
- WordPress audio link not working
- How to disable “Audio Player” to show up on the main page
- how to switch out music file for another using php echo
- How can I convert MP3 file to a Base64 encoded string? [closed]
- How to format strings in Java
- What exactly is Apache Camel?
- What is an instance variable in Java?
- How does the Java ‘for each’ loop work?
- bad operand types for binary operator “&” java
- How can I use pointers in Java?
- How do I generate random integers within a specific range in Java?
- How do I limit the number of decimals printed for a double?
- Unfortunately MyApp has stopped. How can I solve this?
- exception in thread ‘main’ java.lang.NoClassDefFoundError:
- java.io.FileNotFoundException: the system cannot find the file specified
- How to parse this string in Java?
- How to match “any character” in regular expression?
- Explain the use of a bit vector for determining if all characters are unique
- java.text.ParseException: Unparseable date
- Convert java.util.Date to String
- How do I do a deep copy of a 2d array in Java?
- Returning an empty array
- Java Security: Illegal key size or default parameters?
- Could not reserve enough space for object heap
- Eclipse: Java was started but returned error code=13
- What is a safe way to create a Temp file in Java?
- Reason for the exception java.lang.VerifyError: Bad type on operand stack
- java.lang.ArithmeticException: / by zero
- Eclipse error, “The selection cannot be launched, and there are no recent launches”
- STS launch error – Java was started but returned exit code=13
- RecyclerView onClick
- Java, Shifting Elements in an Array
- error: bad operand types for binary operator ‘&&’
- Exception in thread “main” java.lang.ArithmeticException: / by zero
- Failed to load the JNI shared Library (JDK)
- Adding days to a date in Java
- The C# Shorthand getters and setters
- What’s the reason I can’t create generic array types in Java?
- How to pass an object from one activity to another on Android
- Finding the size of a char array in Java
- fixing errors on a program to call methods in java
- How to Set the Background Color of a JButton on the Mac OS
- How to easily convert a BufferedReader to a String?
- How can I calculate a time difference in Java?
- Detecting a long press with Android
- How to increase the size of an array in Java?
- Cannot invoke toString() on the primitive type int
- How fix Error:java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:
- Is it okay to throw NullPointerException programmatically?
- Android: how to create Switch case from this?
- Read next word in java
- Convert float to double without losing precision
- Exception in thread “AWT-EventQueue-0” java.lang.OutOfMemoryError: Java heap space
- How do the post increment (i++) and pre increment (++i) operators work in Java?
- mp3 audio metadata upload integration: can I autopopulate title, caption, description from id3 tags?
- Load MediaPlayerElement after Infinity Scroll loads more posts
- Replace audio links with jplayer using the_content filter
- Can’t upload files 1MB+ [closed]
- How can I upgrade to Java 1.8 on an Amazon Linux Server?