Results 1 to 6 of 6
Thread: Playing mid in java pls help
- 06-18-2010, 09:29 PM #1
Member
- Join Date
- Jun 2010
- Posts
- 3
- Rep Power
- 0
Playing mid in java pls help
Hellou people please i need your help.Im doing tamagotchi and i need music in my program.My problem is:Song dont play good i need to play 1 time no again and again after 4 seconds and mixing to yourself.Please help me? I try everything what i found on net nothing helps.
try {
// From file
Sequence pesnicka = MidiSystem.getSequence(new File("for_elise.mid"));
// Create a sequencer for the sequence
Sequencer sequencer = MidiSystem.getSequencer();
sequencer.open();
sequencer.setSequence(pesnicka);
// Start playing
sequencer.start();
} catch (MalformedURLException s) {
} catch (IOException s) {
} catch (MidiUnavailableException s) {
} catch (InvalidMidiDataException s) {
}
- 06-18-2010, 11:48 PM #2
To fix the looping problem (playing again and again), try this:
Java Code:try { // From file Sequence pesnicka = MidiSystem.getSequence(new File("for_elise.mid")); // Create a sequencer for the sequence Sequencer sequencer = MidiSystem.getSequencer(); sequencer.open(); sequencer.setSequence(pesnicka); // Start playing sequencer.setLoopCount(0); sequencer.start(); } catch (MalformedURLException s) { } catch (IOException s) { } catch (MidiUnavailableException s) { } catch (InvalidMidiDataException s) { }
- 06-19-2010, 01:50 AM #3
Member
- Join Date
- Jun 2010
- Posts
- 3
- Rep Power
- 0
sorry but this no help me...i try but working the same like old one.
- 06-19-2010, 02:56 AM #4
First try running your for_elise.mid in a media player; it may be corrupted (bad MID file) or it may be playing correctly, the song Fur Elise is very repetitive.
Other than that, the only thing I can suggest is putting sequencer.open(); after sequencer.setSequence(pesnicka);.
PS: I'm headed home now, I'll test this code out when I get there.
- 06-19-2010, 03:06 AM #5
Member
- Join Date
- Jun 2010
- Posts
- 3
- Rep Power
- 0
I try more than one song...and i use media player .) something must be wrong
- 06-20-2010, 06:15 AM #6
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
Similar Threads
-
Playing an Animated GIF
By c0m4ndo45 in forum Java 2DReplies: 3Last Post: 04-24-2009, 10:47 AM -
playing audio in J-App??
By ashton in forum New To JavaReplies: 3Last Post: 01-30-2009, 08:50 AM -
Java Error when playing POGO
By coffeeswirlz in forum Advanced JavaReplies: 1Last Post: 11-25-2008, 02:34 AM -
Re-playing sound
By JSK in forum CLDC and MIDPReplies: 0Last Post: 02-06-2008, 11:34 AM -
Playing sound in applet??????
By Bagesh in forum Java AppletsReplies: 2Last Post: 07-13-2007, 04:46 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks