If you would like to use an Embed code for playing the song then you can use this code ,:)
Code for playing a MP3 song in Java ,
public static void main(String args) throws Exception
// Take the path of the audio file from command line
File f=new File(args);
// Create a Player object that realizes the audio
final Player p=Manager.createRealizedPlayer(f.toURI().toURL());
// Start the music
// Create a Scanner object for taking input from cmd
Scanner s=new Scanner(System.in);
// Read a line and store it in st
// If user types 's', stop the audio
Player is an interface in the javax.media package. As you cannot create an object for an interface directly some class implementing it is written and it's object is used. Manager is such a class that does the thing.
There are several states in which a Player will be. They are
UNREALIZED: Meaning, the player knows nothing about what it has to do (about the media)
REALIZING: Meaning, the player is realizing it's world (determining resources) necessary to do the job (playing the file)
REALIZED: Meaning, the player gets its resources to play the file and will also have some info about the type of the media etc.
PREFETCHING: It's getting ready now, it is knowing how could it play the file.
PREFETCHED: Now, it knows how to play the media. It can fire now.
START: Start the music, starts playing the file.
We have created a realized player, it does not mean that the UNREALIZED, REALIZING steps are skipped instead they are automatically done. The method createRealizedPlayer(URL url) takes a URL which points to the media file. For getting the URL object from a File object, you can used toURL() method in the java.io.File class, as it is deprecated we've called toURI() method which returns java.net.URI object and then the toURL() method in it.The user also needs to stop the music, so input is taken from the user.
Output however cannot be shown, you'll have to try it, remember that when executing the program give the complete path of the audio file otherwise ArrayIndexOutOfBounds exception will arise. The command might look like this
java AudioPlay "Path/to/file.mp3"
Credit Goes to Java Demo