ok so I have this sound code I use for all my stuff I need sound in, I used it last about 1 or 2 months ago and it worked, I had it in 2 applications that unfortunatley I don't have anymore and it worked it played sound and I could make it loop and wahtever I wanted
but now it has stopped working, it doesn't generate any errors it just doesn't play the sound, I checked if it is running the code and it is I've tried running it in a new application and I tried a new thread in the current application and nothing worked
here's the code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| import java.net.URL;
import javax.sound.midi.*;
public class Music {
public Music() { Thread t = new Thread(new Runnable() { @Override public void run() { pplay(); } });t.start(); } public void pplay() { try { URL url = new URL("file:c:/theme.mid"); System.out.println("Started"); sequence = MidiSystem.getSequence(url); sequencer = MidiSystem.getSequencer();
sequencer.open(); sequencer.setSequence(sequence);
sequencer.start(); System.out.println("Done"); } catch(Exception e) { e.printStackTrace(); } }
public static Sequence sequence; public static Sequencer sequencer; } |
I just want to know if I'm missing something, or is there something wrong with my java nothing has changed since I last used this code