public static void playMidi(Sequence midi)
	{
		try
		{
			if(sequencer == null)
				sequencer = MidiSystem.getSequencer();
	        if(sequencer.isOpen())
	        {
	        	sequencer.stop();
	        	sequencer.setTickPosition(0);
	        }
	        
	        if(midi == null)
			{
	        	sequencer.stop();
				sequencer.close();
				return;
			}
	        
	        sequencer.setLoopCount(Sequencer.LOOP_CONTINUOUSLY);
	        //sequencer.setLoopCount(0);
	        sequencer.setSequence(midi);
	        sequencer.open();
	
	        sequencer.start();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}