First time here? Check out the FAQ!
x

How to play an audio in Netbeans 7.3.1?

0 votes
asked by (340 points)
edited by

How to play an audio in Netbeans 7.3.1?

1 Answer

0 votes
answered by (264k points)

Java 7 contains two classes that allow you to play audio files: Media and MediaPlayer.

String bip = "bip.mp3";
Media hit = new Media(bip);
MediaPlayer mediaPlayer = new MediaPlayer(hit);
mediaPlayer.play();

then add the following lines to your program:

import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register
...