Hi also ich hab eine musikdatei die ich mit einen javaprogramm abspielen pausieren stoppen usw. möchte
hab eine gui oberfläche mit den jeweiligen Oberflächen erstellt. Das abspielen funktioniert auch wunderbar bloß ich kann jetzt gar nix mehr anklicken also gar keinen botton. muss ich da irgend eine code schreiben das ich während eines event andere event starten kann???
hier meine action performed methode
hab eine gui oberfläche mit den jeweiligen Oberflächen erstellt. Das abspielen funktioniert auch wunderbar bloß ich kann jetzt gar nix mehr anklicken also gar keinen botton. muss ich da irgend eine code schreiben das ich während eines event andere event starten kann???
hier meine action performed methode
Java:
public void actionPerformed(ActionEvent e) {
boolean Play = false,Stop=false,Pause=false,Next=false;//Wahrheitswerte was momentan ausgeführt wird
if(playlist.isEmpty()==false){
if(e.getActionCommand().equals("AC_PLAY")){
Play=true;
Stop=false;
AudioFile af = playlist.getCurrentAudioFile(); //aktueller Song bzw. Audiodatei
try {
af.play();//lässt den Song abspielen
} catch (NotPlayableException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
System.out.println("Playing:"+af.toString());
System.out.println("Filname is: "+af.getFilename());
System.out.println("current: "+playlist.getCurrent());}
if(e.getActionCommand().equals("AC_PAUSE")){
AudioFile af = playlist.getCurrentAudioFile();
if(Play==true){
af.togglePause();//unterbricht das Lied
Pause=true;
}
if(Pause==true){
Play=true;
try {
af.play();
} catch (NotPlayableException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Pause=false;
}
System.out.println("Pausing:"+af.toString());
System.out.println("Filname is: "+af.getFilename());
System.out.println("current: "+playlist.getCurrent());}
if(e.getActionCommand().equals("AC_STOP")){
AudioFile af = playlist.getCurrentAudioFile();
af.stop();
playTime1.setText(playTime);
System.out.println("Stoping:"+af.toString());
System.out.println("Filname is: "+af.getFilename());
System.out.println("current: "+playlist.getCurrent());}
if(e.getActionCommand().equals("AC_NEXT")){
playlist.changeCurrent();
AudioFile af = playlist.getCurrentAudioFile();
songDescription.setText(af.toString());
setTitle(currentsong+af.toString());
//playTime1.setText(af.getFormattedDuration());//später durch getFormattedPosition ersetzten
System.out.println("Switching to NEXT AudioFile:"+af.toString());
System.out.println("Filname is: "+af.getFilename());
System.out.println("current: "+playlist.getCurrent());}
}
}