i tried make music player java. not test codes , try make music player own way. music player can play 1 song/sound. there textfield need write song file location. example can write epic.wav , play epic.wav, want listen asd.wav if write player still play epic.wav.
there code sound.java
import java.applet.applet; import java.applet.audioclip; class sound { public static final sound sound1 = new sound(form.soundstring); private audioclip clip; public sound(string filename){ try{ clip = applet.newaudioclip(sound.class.getresource(filename)); }catch(exception e){ e.printstacktrace(); } } public void play(){ try{ new thread(){ public void run(){ clip.play(); } }.start(); }catch(exception ex){ ex.printstacktrace(); } } } and there code form.java
public class form extends javax.swing.jframe { public form() { initcomponents(); } public static string soundstring; private sound sound; @suppresswarnings("unchecked") private void exitbuttonmouseclicked(java.awt.event.mouseevent evt) { system.exit(0); } private void minibuttonmouseclicked(java.awt.event.mouseevent evt) { this.setstate(form.iconified); } private void jbutton1mouseclicked(java.awt.event.mouseevent evt) { soundstring = jtextfield1.gettext(); sound.sound1.play(); } so there codes... , want know why play 1 song.
thanks helping!
Comments
Post a Comment