Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (577)
games submitted by our members
Games in WIP (498)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Why isn't my sound working anymore  (Read 2890 times)
0 Members and 1 Guest are viewing this topic.
Offline Quadro

Senior Newbie





« Posted 2012-08-26 01:30:48 »

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() {
      // TODO Auto-generated method stub
     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
Offline philfrei
« Reply #1 - Posted 2012-08-27 19:16:17 »

The "sound chain" involves code both in Java and in the OS. Has anything changed outside of Java, in your OS or computer, that might account for this?

Can you execute a dump of the MIDI data? (Verify that the data is actually there, and a sequencer instance is actually there, etc.)

I'm more experienced with the javax.sound.sampled end of things, not MIDI. There was one change when we went to Java 7 that had an effect (involving InputStreams), but it doesn't apply to your situation, afaik. So, am just suggesting some basic troubleshooting.

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline nsigma
« Reply #2 - Posted 2012-08-27 20:18:28 »

The MIDI synthesizer changed completely between Java 6 and Java 7. If you've upgraded since you last used this code then that could be the reason. You might have to try the methods that let you set the synthesiser manually and see if any work as you're expecting.

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Quadro

Senior Newbie





« Reply #3 - Posted 2012-08-27 20:31:23 »

The MIDI synthesizer changed completely between Java 6 and Java 7. If you've upgraded since you last used this code then that could be the reason. You might have to try the methods that let you set the synthesiser manually and see if any work as you're expecting.

oh ya I just tried using java 7 to compile it with and the sound plays yay, but one problem, if I have this precompiled with java 7 will someone who is using java 6 be able to hear the music or will it not work?
Offline Rorkien
« Reply #4 - Posted 2012-08-27 20:48:14 »

The MIDI synthesizer changed completely between Java 6 and Java 7. If you've upgraded since you last used this code then that could be the reason. You might have to try the methods that let you set the synthesiser manually and see if any work as you're expecting.

oh ya I just tried using java 7 to compile it with and the sound plays yay, but one problem, if I have this precompiled with java 7 will someone who is using java 6 be able to hear the music or will it not work?

No.
And as far as i'm concerned, it will greet you with an Exception
Offline gimbal

JGO Coder


Medals: 25



« Reply #5 - Posted 2012-08-30 14:03:58 »

The MIDI synthesizer changed completely between Java 6 and Java 7. If you've upgraded since you last used this code then that could be the reason. You might have to try the methods that let you set the synthesiser manually and see if any work as you're expecting.

oh ya I just tried using java 7 to compile it with and the sound plays yay, but one problem, if I have this precompiled with java 7 will someone who is using java 6 be able to hear the music or will it not work?

No.
And as far as i'm concerned, it will greet you with an Exception

Java 7 is indeed not bytecode compatible with Java 6 - you can't run applications built for Java 7 on a Java 6 runtime.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (22 views)
2014-04-15 18:08:23

BurntPizza (17 views)
2014-04-15 03:46:01

UprightPath (31 views)
2014-04-14 17:39:50

UprightPath (15 views)
2014-04-14 17:35:47

Porlus (31 views)
2014-04-14 15:48:38

tom_mai78101 (57 views)
2014-04-10 04:04:31

BurntPizza (115 views)
2014-04-08 23:06:04

tom_mai78101 (214 views)
2014-04-05 13:34:39

trollwarrior1 (182 views)
2014-04-04 12:06:45

CJLetsGame (189 views)
2014-04-01 02:16:10
List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:05:20
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!