error.jpg
package itproj;
import java.awt.FlowLayout;
import java.io.File;
import javax.media.Format;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.Player;
import javax.media.PlugInManager;
import javax.media.format.AudioFormat;
import javax.swing.JApplet;
import javax.swing.JLabel;
/**
*
* @author karl
*/
public class Sounds extends JApplet {
JLabel TITLE = new JLabel("Mp3 player stand alone");
/**
*
*/
@Override
public void init() {
setLayout(new FlowLayout());
getContentPane().add(TITLE);
Format input_mp3 = new AudioFormat(AudioFormat.MPEGLAYER3);
Format input_mpeg = new AudioFormat(AudioFormat.MPEG);
Format output = new AudioFormat(AudioFormat.LINEAR);
PlugInManager.addPlugIn("com.sun.media.codec.audio .mp3.JavaDecoder",
new Format[]{input_mp3,input_mpeg},
new Format[]{(output)},PlugInManager.CODEC
);
try{
String SubDirectory = "Music/";
String FileName;
FileName = "02-311-love_song-legacymp3.mp3";
FileName = Get_File_Location(FileName, SubDirectory);
System.out.println(FileName);
Player PLAYER = Manager.createPlayer( new MediaLocator(
new File(FileName).toURI().toURL() ) );
PLAYER.start();
}catch(Exception X){
X.printStackTrace();
}
// TODO overwrite start(), stop() and destroy() methods
}
private String Get_File_Location(String FileName, String SubDirectory)
{
FileName = SubDirectory + FileName;
FileName = this.getClass().getResource(FileName).toString();
FileName = FileName.replace("/", "\\\\");
FileName = FileName.substring(7);
return FileName;
}
}