<repo_name>Dauta/Nebula<file_sep>/src/nebula/player/Glass.java
package player;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

public class Glass extends JPanel implements ActionListener
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	Music music;
	String ttl = "     ";
	JLabel title;
	public Glass(Music m)
	{
		
		new Timer(30, this).start();
		
		this.setLayout(new BorderLayout());
		music = m;
		music.playButton.addActionListener(music.PlayMp3);				//or play WAV
		music.stopButton.addActionListener(music.StopMp3);
		music.nextButton.addActionListener(music.nextBtnListener);
		music.prevButton.addActionListener(music.prevBtnListener);
	
		ImageIcon playIcon = new ImageIcon("E:\\Projects\\Nebula\\src\\Image\\playBtn2.png");
		music.playButton.setBorder(BorderFactory.createEmptyBorder());
		music.playButton.setContentAreaFilled(false);
		music.playButton.setFocusable(false);
		music.playButton.setIcon(playIcon);
		music.playButton.setSize((int)MusicPlayer.masterSize.getWidth() * 5/100, (int)MusicPlayer.masterSize.getWidth() * 5/100);
		music.playButton.setPreferredSize(music.playButton.getSize());
		
		ImageIcon stopIcon = new ImageIcon("E:\\Projects\\Nebula\\src\\Image\\stopBtn2.png");
		music.stopButton.setBorder(BorderFactory.createEmptyBorder());
		music.stopButton.setContentAreaFilled(false);
		music.stopButton.setFocusable(false);
		music.stopButton.setIcon(stopIcon);
		music.stopButton.setSize((int)MusicPlayer.masterSize.getWidth() * 5/100, (int)MusicPlayer.masterSize.getWidth() * 5/100);
		music.stopButton.setPreferredSize(music.stopButton.getSize());
	
		ImageIcon nextIcon = new ImageIcon("E:\\Projects\\Nebula\\src\\Image\\nextBtn.png");
		music.nextButton.setBorder(BorderFactory.createEmptyBorder());
		music.nextButton.setContentAreaFilled(false);
		music.nextButton.setFocusable(false);
		music.nextButton.setIcon(nextIcon);
		music.nextButton.setSize((int)MusicPlayer.masterSize.getWidth() * 5/100, (int)MusicPlayer.masterSize.getWidth() * 5/100);
		music.nextButton.setPreferredSize(music.stopButton.getSize());
		
		ImageIcon prevIcon = new ImageIcon("E:\\Projects\\Nebula\\src\\Image\\prevBtn.png");
		music.prevButton.setBorder(BorderFactory.createEmptyBorder());
		music.prevButton.setContentAreaFilled(false);
		music.prevButton.setFocusable(false);
		music.prevButton.setIcon(prevIcon);
		music.prevButton.setSize((int)MusicPlayer.masterSize.getWidth() * 5/100, (int)MusicPlayer.masterSize.getWidth() * 5/100);
		music.prevButton.setPreferredSize(music.stopButton.getSize());
	
		JPanel buttonPanel = new JPanel();
		buttonPanel.setSize((int)MusicPlayer.masterSize.getWidth() * 95/100, (int)MusicPlayer.masterSize.getHeight() * 10/100 );
		buttonPanel.setPreferredSize(buttonPanel.getSize());
		buttonPanel.setBackground(new Color(0,0,0,0));
		
		buttonPanel.add(music.prevButton);
		buttonPanel.add(music.playButton);	
		buttonPanel.add(music.stopButton);	
		buttonPanel.add(music.nextButton);
		
		this.add(buttonPanel, BorderLayout.NORTH);
	
	}	
		
	@Override
	public void actionPerformed(ActionEvent arg0) {
		if(ttl != ClickableLabel.songName)
		{
			try
			{
			this.remove(title);
			}
			catch(Exception e)
			{
				title = new JLabel(" ");
				this.add(title,BorderLayout.NORTH);
				//e.printStackTrace();
			}
		//	System.out.println(ttl + "first");
			ttl = ClickableLabel.songName;
		//	System.out.println(ttl + "second");
			title = new JLabel(ttl);
			title.setFont(new Font("Calibri", Font.LAYOUT_LEFT_TO_RIGHT, 25));
			title.setForeground(new Color(250,250,250));
		
			
			this.add(title,BorderLayout.NORTH);
			revalidate();
		}
		
	}
	
}
<file_sep>/src/nebula/player/MenuBar.java
package player;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map.Entry;

@SuppressWarnings("serial")
public class MenuBar extends JMenuBar
{

	Playlist list;
	JMenu file, playlist;
	JMenuItem open, importFolder, createNewPlaylist, save, load;
	JFileChooser fileChooser;
	public File selectedFile;
	public ClickablePlaylist cp;
	JPanel panel, bigPanel;
	
	public MenuBar(Playlist pl, JPanel p, JPanel p2)
	{
		
		panel = p;
		bigPanel = p2;
		this.setBackground(new Color(100,200,200,20));
		
		file = new JMenu("File");
		file = new JMenu("Folder");
		playlist = new JMenu("Playlist");
		
		open = new JMenuItem("Open File...");
		importFolder = new JMenuItem("Import a Folder...");
		createNewPlaylist = new JMenuItem("Create new Playlist...");
		save = new JMenuItem("Save Playlists...");
		load = new JMenuItem("Load Playlist...");
		
		open.addActionListener(openFileListener);
		createNewPlaylist.addActionListener(createNewList);
		save.addActionListener(saveListener);
		load.addActionListener(loadListener);
		playlist.add(createNewPlaylist);
		playlist.add(save);
		playlist.add(load);
		file.add(open);
		file.add(importFolder);
	
		this.add(playlist);
		this.add(file);		
		
		this.setVisible(true);
		list = pl;
		
	}

	public static void infoBox(String infoMessage, String titleBar)
    {
        JOptionPane.showMessageDialog(null, infoMessage, "InfoBox: " + titleBar, JOptionPane.INFORMATION_MESSAGE);
    }
	
	ActionListener openFileListener = new ActionListener()
	{
		@Override
		public void actionPerformed(ActionEvent arg0) {
			
			
			if(!(Playlist.name == null))
			list.OpenSingleFile();
			else
			{
				infoBox("Create a playlist first", "Oops");
				cp = new ClickablePlaylist(panel, bigPanel, list);	
				cp.insertPlaylist();
			}
		}
		
	};
	
	ActionListener playlistListener = new ActionListener()
	{
		public void actionPerformed(ActionEvent arg0) {
	
			if(Playlist.name != null)
			{
				list.GetList();
			}
			else
			{
				infoBox("Create a playlist first", "Oops");
				cp = new ClickablePlaylist(panel, bigPanel, list);	
				cp.insertPlaylist();
			}
			
			
		}
	};
	
	ActionListener saveListener = new ActionListener()
	{

		@Override
		public void actionPerformed(ActionEvent arg0) {
			
			savePlaylist();
			
		}
		
	};
	
	ActionListener createNewList = new ActionListener()
	{

		@Override
		public void actionPerformed(ActionEvent e) 
		{  
			cp = new ClickablePlaylist(panel, bigPanel, list);	
			cp.insertPlaylist();	
		}
		
	};
	
	ActionListener loadListener = new ActionListener()
	{

		@Override
		public void actionPerformed(ActionEvent arg0) 
		{
			LoadPlaylist();
		}
		
	};
	
	public void ChoosePlaylistFolder()
	{
		importFolder.addActionListener(playlistListener);
	}
	
	void savePlaylist()
	{
		String userName = System.getProperty("user.name");
		String savePath = "C:\\Users\\"+userName+"\\Documents\\TheMusicPlayer";
		
		File f = new File(savePath);
		
		if(f.exists() && f.isDirectory())
		{
			File old = new File(savePath + "\\playlist.txt");
			old.delete();
		
		try{
			  FileWriter fstream = new FileWriter(savePath + "\\playlist.txt");
			  BufferedWriter out = new BufferedWriter(fstream);
			 
			Iterator<Entry<String, LinkedHashMap>> it = list.mainList.entrySet().iterator();
			while(it.hasNext())
			{
				Entry<String, LinkedHashMap> currentList = it.next();
				LinkedHashMap<String, String> currentMap = currentList.getValue();
		
				out.write(currentList.getKey()+"FFFF");
				out.newLine();
				
				
				Iterator<Entry<String, String>> it2 = currentMap.entrySet().iterator();
				while(it2.hasNext())
				{
				Entry<String, String> thePlaylist = it2.next();
				
				out.write(thePlaylist.getKey()+"SSSPLITTERRR"+thePlaylist.getValue());
				out.newLine();
				}
			}
			  
			  
			  
			  
			  
			  
			  //out.write("Hello Java");
			  //Close the output stream
			  out.close();
			}
			catch(Exception e)
			{
				e.printStackTrace();
			}
		}
		else
		{
			f.mkdir();
			
			try{
				  FileWriter fstream = new FileWriter(f.getAbsolutePath()+"\\playlist.txt");
				  BufferedWriter out = new BufferedWriter(fstream);
				 
				Iterator<Entry<String, LinkedHashMap>> it = list.mainList.entrySet().iterator();
				while(it.hasNext())
				{
					Entry<String, LinkedHashMap> currentList = it.next();
					LinkedHashMap<String, String> currentMap = currentList.getValue();
			
					out.write(currentList.getKey());
					out.newLine();
					
					Iterator<Entry<String, String>> it2 = currentMap.entrySet().iterator();
					while(it2.hasNext())
					{
					Entry<String, String> thePlaylist = it2.next();
					
					out.write(thePlaylist.getKey()+" "+thePlaylist.getValue());
					out.newLine();
					}
				}
				  out.close();
		}
			catch(Exception e)
			{
				e.printStackTrace();
			}	
		}
	}
	
	void LoadPlaylist()
	{

		String userName = System.getProperty("user.name");
		String loadPath = "C:\\Users\\"+userName+"\\Documents\\TheMusicPlayer\\playlist.txt";
		BufferedReader br;
		File f = new File(loadPath);
		String tempOuterKey = null;
		String tempInnerKey = null;
		String tempInnerValue = null;
		LinkedHashMap<String, String> tempMap = new LinkedHashMap<String,String>();
		String currentLine; 
		String toBeName = null;
		
		if(f.exists())
		{
			
			try
			{
				br = new BufferedReader(new FileReader(loadPath));
		
				while ((currentLine = br.readLine()) != null) 
				{
				//	System.out.println(currentLine);
					
					if(currentLine.substring(currentLine.length() - 4).equals("FFFF"))
					{
						tempOuterKey = currentLine.substring(0, currentLine.length() - 4);
						toBeName = tempOuterKey;
						//System.out.println(tempOuterKey+" tempOuterKey");
						tempMap.clear();
					}
					else
					{
						String[] splitString = currentLine.split("SSSPLITTERRR");
						tempInnerKey = splitString[0];
						System.out.println(tempInnerKey);
					    tempInnerValue = splitString[1];
						System.out.println(tempInnerValue);
						//tempMap = new LinkedHashMap<String,String>();
						tempMap.put(tempInnerKey, tempInnerValue);
					}
					
					//System.out.println(tempMap);
					LinkedHashMap<String, String> asd = new LinkedHashMap<String, String>();
					
					asd.putAll(tempMap);
					list.mainList.put(tempOuterKey, asd);
					//tempMap.clear();
					
				}
				System.out.println(list.mainList);
			//	playlist.name = list.mainList.
				//System.out.println("asd");
				
				br.close();
				
			}
			catch(Exception e)
			{
				e.printStackTrace();
			}
		
		}
		
		
		System.out.println(list.mainList);
		Iterator<String> it = list.mainList.keySet().iterator();
		while(it.hasNext())
		{
			String curr = it.next();
			
			System.out.println(curr);
			
			ClickablePlaylist playlistToCreate = new ClickablePlaylist(panel, bigPanel, list, curr);
			playlistToCreate.autoInsertPlaylist();
		}
		
		Playlist.name = toBeName;
		System.out.println(list.mainList);
	}
}
<file_sep>/src/nebula/player/BackGround.java
package player;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;

import javax.swing.JPanel;

class BackGround extends JPanel							//class for drawing background elements animating dots
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	double screenWidth = screenSize.getWidth();
	double screenHeight = screenSize.getHeight();

	private Random randomCoordinate = new Random();						//random number generator for initial coordinates;
	private int numberOfDots = (int) (screenWidth * screenHeight) / 8000;
	
	int[] x = new int[numberOfDots];
	int[] y = new int[numberOfDots];
	boolean[] flagX = new boolean[numberOfDots];
	boolean[] flagY = new boolean[numberOfDots];
	
	public BackGround()
	{
		for(int i = 0; i<numberOfDots; i++)
		{
			x[i] = 10 + randomCoordinate.nextInt((int)screenWidth - 10);
			y[i] = 10 + randomCoordinate.nextInt((int)screenHeight - 10);
		}	
	}
	
	@Override
	protected void paintComponent(Graphics g)
	{
		
		Graphics2D g2 = (Graphics2D) g;								//
		g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,		//ANTIALIASED PANEL!!!!!
         RenderingHints.VALUE_ANTIALIAS_ON);						//
        
		super.paintComponent(g2);
		super.paintComponent(g);
		
		for(int j = 0; j<numberOfDots; j++)				//draw circles
		{
			g.setColor(new Color(204,229,255));
			g.fillOval(x[j], y[j], 4, 4);	
		}
		
		for(int a = 0; a<numberOfDots; a++)					//draw lines
		{
			for(int b=0; b<numberOfDots; b++)
			{
				if((Math.abs(x[a] - x[b]) < 50) && (Math.abs(y[a]-y[b]) < 50))
				{
						g.setColor(new Color(204,229,255, 255));
						g.drawLine(x[a], y[a], x[b], y[b]);		
				}
				if((Math.abs(x[a] - x[b]) < 60) && (Math.abs(y[a]-y[b]) < 60))
				{
						g.setColor(new Color(204,229,255, 200));
						g.drawLine(x[a], y[a], x[b], y[b]);		
				}
				if((Math.abs(x[a] - x[b]) < 70) && (Math.abs(y[a]-y[b]) < 70))
				{
						g.setColor(new Color(204,229,255, 150));
						g.drawLine(x[a], y[a], x[b], y[b]);		
				}
				if((Math.abs(x[a] - x[b]) < 80) && (Math.abs(y[a]-y[b]) < 80))
				{
						g.setColor(new Color(204,229,255, 100));
						g.drawLine(x[a], y[a], x[b], y[b]);		
				}
				if((Math.abs(x[a] - x[b]) < 90) && (Math.abs(y[a]-y[b]) < 90))
				{
						g.setColor(new Color(204,229,255, 50));
						g.drawLine(x[a], y[a], x[b], y[b]);		
				}
				if((Math.abs(x[a] - x[b]) < 100) && (Math.abs(y[a]-y[b]) < 100))
				{
						g.setColor(new Color(204,229,255, 20));
						g.drawLine(x[a], y[a], x[b], y[b]);		
				}
			}
		}
   }

	ActionListener update = new ActionListener() {
	@Override
	public void actionPerformed(ActionEvent arg0)
		{
		// TODO Auto-generated method stub
		for(int k = 0; k < numberOfDots; k++)
		{
			if(x[k] == screenWidth)
				flagX[k] = true;
			else if(x[k] == 0)
				flagX[k] = false;
			if(y[k] == screenHeight)
				flagY[k] = true;
			else if(y[k] == 0)
				flagY[k] = false;
			
			//motion algorithm 
			if(!flagX[k] && !flagY[k])
			{
				if(k%2 == 0)
					{
					x[k] += 0.9;
					y[k] += 1.1;
					}
				else if(k%3 == 0)
					{
					x[k] += 1.7;
					y[k] += 1.8;
					}
				else if(k%5 == 0)
				{
					x[k] += 1.4;
					y[k] += 2.0;
				}
				else 
				{
					x[k] += 1.1;
					y[k] += 0.9;
				}	
				
			}

			else if(flagX[k] && flagY[k])
			{
				if(k%2 == 0)
				{
				x[k] -= 0.9;
				y[k] -= 1.1;
				}
			else if(k%3 == 0)
				{
				x[k] -= 1.7;
				y[k] -= 1.8;
				}
			else if(k%5 == 0)
			{
				x[k] -= 1.4;
				y[k] -= 2.0;
			}
			else 
			{
				x[k] -= 1.1;
				y[k] -= 0.9;
			}	
					
			}

			else if(flagX[k] && !flagY[k])
			{
				if(k%2 == 0)
				{
				x[k] -= 0.9;
				y[k] += 1.1;
				}
			else if(k%3 == 0)
				{
				x[k] -= 1.7;
				y[k] += 1.8;
				}
			else if(k%5 == 0)
			{
				x[k] -= 1.4;
				y[k] += 2.0;
			}
			else 
			{
				x[k] -= 1.1;
				y[k] += 0.9;
			}	
					
			}

			else if(!flagX[k] && flagY[k])
			{
				if(k%2 == 0)
				{
				x[k] += 0.9;
				y[k] -= 1.1;
				}
			else if(k%3 == 0)
				{
				x[k] += 1.7;
				y[k] -= 1.8;
				}
			else if(k%5 == 0)
			{
				x[k] += 1.4;
				y[k] -= 2.0;
			}
			else 
			{
				x[k] += 1.1;
				y[k] -= 0.9;
			}	
					
			}
			//end motion algorithm
			
		}
			repaint();
	
	}
	};
	
	public void addGlass(JPanel glass)
	{
		
		//this.setLayout(new BorderLayout());
		glass.setBackground(new Color(40,40,50,130));
		//glass.setSize((int)MusicPlayer.masterSize.getWidth(), (int)MusicPlayer.masterSize.getHeight());
		//glass.setPreferredSize(glass.getSize());
		this.add(glass, BorderLayout.CENTER);
	}	
}<file_sep>/src/nebula/player/Music.java
package player;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.util.Iterator;
import java.util.Map.Entry;

import javax.swing.ImageIcon;
import javax.swing.JButton;

import javazoom.jl.player.Player;
import javazoom.jl.decoder.Equalizer;

public class Music
{
	
	 String bufferedSong; 	
	 String fileName;
	 int songCounter = 0;
	 Player mp3player;
	 MenuBar menu;
	 Playlist playlist;
	 boolean nowPlaying = false;
	 boolean nowPaused = false;
	 boolean finished = true;
	 JButton playButton = new JButton("Play");
	 JButton stopButton = new JButton("Stop");
	 JButton nextButton = new JButton("Next");
	 JButton prevButton = new JButton("Previous");
	 public BufferedInputStream buffStream;
	 public FileInputStream stream;
	 long audioLength = 0;
	 long audioPaused = 0;
	 Thread musicThread;  
	 String song;
	// String currentSong;
	 
	 public Music(MenuBar mb, Playlist pl)
	 {
		 		menu = mb;
		 	    playlist = pl;
	 }
	
	void LoadStream()
	{
		
		try
		{	
			song = ClickableLabel.songName;
			fileName = (String)playlist.mainList.get(Playlist.name).get(song);
			
			
			stream = new FileInputStream(fileName);
			audioLength = stream.available();				//get the length of a full file in bytes;
			buffStream = new BufferedInputStream(stream);			
			mp3player = new Player(buffStream);		
			
		}
		catch (Exception e)
		{
				System.out.println(e);
				e.printStackTrace();
		}
		
		
	}
	
	ActionListener PlayMp3 = new ActionListener()
	{
		@Override
	public void actionPerformed(ActionEvent arg0)
	{
			if(song == null)
			{
				playlist.OpenSingleFile();
			}
			else
			{
			Play();
			}
	}
			
	};			//end PlayMp3 ActionListener
	
	ActionListener StopMp3 = new ActionListener()
	{
		public void actionPerformed(ActionEvent args0)
		{
			Stop();
		}
				
	};
	
	ActionListener PauseMp3 = new ActionListener()
	{
		public void actionPerformed(ActionEvent args0)
		{
			Pause();
		}	
	};
	
	ActionListener durationListener = new ActionListener()
	{
		@Override
		public void actionPerformed(ActionEvent args0)
		{
				CheckDuration();
		}
	};
	
	ActionListener changeListener = new ActionListener()				//check this!!!!!
	{
		@Override
		public void actionPerformed(ActionEvent e) 
		{
			if(song != ClickableLabel.songName)
			{
					Stop();
					Play();
			}
		}
	};
	
	ActionListener nextBtnListener = new ActionListener()
	{
		@Override
		public void actionPerformed(ActionEvent e)
		{
			Stop();	
			
			try
			{
			//automaticly go to the next one;
				
				System.out.println("asd");
			Iterator<Entry<String, String>> it = playlist.mainList.get(Playlist.name).entrySet().iterator();
			while(it.hasNext())
			{	
				
			//	System.out.println(ClickableLabel.songName + "whatever");
				Entry<String, String> curr = it.next();
				//System.out.println(curr.getKey());
				if(curr.getKey().equals(song))
				{
					ClickableLabel.songName = it.next().getKey();
					System.out.println(ClickableLabel.songName);
					break;
				}
			}
			}
			catch(Exception asd)
			{
				System.out.println("no more");
			}
		}
	};
	
	ActionListener prevBtnListener = new ActionListener()
	{
		@Override
		public void actionPerformed(ActionEvent e) 
		{			
			try
			{
			//automaticly go to the previous one
				Stop();	
			Iterator<Entry<String, String>> it = playlist.mainList.get(Playlist.name).entrySet().iterator();
			while(it.hasNext())
			{	
				String[] curr = new String[100];
				
				for(int i = 0; i<playlist.mainList.get(Playlist.name).size(); i++)
				{
				 curr[i] = it.next().getKey();
				if(curr[i].equals(song))
				{
					if(i > 0)
					{
					ClickableLabel.songName = curr[i-1];
					break;
					}
				}
				}
			}
			}
			catch(Exception ex)
			{
				Play();
			}
		}
		
	};
	
	void Play()
	{
		// LoadStream();
		
		musicThread = new Thread() {
	        public void run() {
	            try 
	            {
	        //    	System.out.println("New Thread");
	            //	System.out.println(ClickableLabel.songName);
	            	mp3player.play();
	            	
	            	
	            	
	            	
	         //   	System.out.println("Thread finished");
	            }
	            catch (Exception e) 
	            { 
	            	System.out.println(e); 
	            	e.printStackTrace();
	            }
	        }
	    };
	    
	    
	 //  System.out.println( musicThread.getUncaughtExceptionHandler());
		
	//    song = ClickableLabel.songName;
		if(nowPlaying == false && nowPaused == false && finished == true)
		{
			//get a file path and set up streams and player
			 LoadStream();
			 	
			musicThread.start();					//start thread to play music
			nowPlaying = true;						//nowPlaying flag set to true
			finished = false;
		}
		
		else if(nowPaused == true)			
		{
			 try													//get a file path and set up streams and player
				{	
				LoadStream();
				 	
				// ClickableLabel.songName = currentSong;
				// System.out.println(audioLength);
				buffStream.skip(audioLength - audioPaused - 25000);
					musicThread.start();
					audioPaused = 0;						//reset the byte counter 
					nowPaused = false;						//reset the nowPaused flag
					nowPlaying = true;						//set the nowPlaying flag
							
				}
					catch (Exception e)
				{
						System.out.println(e);
						e.printStackTrace();
				}

		}
		
		else
		{
			System.out.println("Already Playing can't start another");
		}
	
		ChangeButton();
		
	}       // end Play()
	
	
	
	public void Stop()
	{
		if(nowPlaying == true)
		{
		try
		{
	//		System.out.println("stopped");
			mp3player.close();
			nowPlaying = false;
			nowPaused = false;
			audioPaused = 0;				//reset the byte counter;	
			ChangeButton();
			finished = true;
		//	System.out.println("stop finished");
			musicThread.interrupt();
		}
		catch (Exception e)
		{
			System.out.println("nothing to stop");
			e.printStackTrace();
		}
		
		}
		
		else if(nowPaused == true)
		{
			audioPaused = 0;
			nowPaused = false;
			nowPlaying = false;
			finished = true;
		}
		else
		{
			System.out.println("can't stop");
		}
	}				
	//end Stop();

	public void Pause()
	{
		System.out.println("Paused");
		try {
			this.audioPaused = stream.available();		
	//		System.out.println(audioPaused);
		}
			catch (Exception e) 
		{
			e.printStackTrace();
		}	
		
		musicThread.interrupt();
		mp3player.close();
		this.nowPlaying = false;		
		this.nowPaused = true;
		this.finished = false;
		ChangeButton();		
		
	}		
	//end Pause();
	
	void ChangeButton()
	{
		if (nowPlaying == true)
		{
			playButton.removeActionListener(PlayMp3);
			playButton.addActionListener(PauseMp3);
			//playButton.setText("Pause");
			playButton.setIcon(new ImageIcon("src\\Image\\pauseBtn2.png"));
			//System.out.println("1");
		}
		else if (nowPlaying == false)
		{
			playButton.removeActionListener(PauseMp3);
			playButton.addActionListener(PlayMp3);
			playButton.setIcon(new ImageIcon("src\\Image\\playBtn2.png"));
		//	System.out.println("2");
		}
		else if(finished == true)
		{
			playButton.removeActionListener(PauseMp3);
			playButton.addActionListener(PlayMp3);
			playButton.setIcon(new ImageIcon("src\\Image\\playBtn2.png"));
			//System.out.println("2");
			audioPaused = 0;
		}
	}
	//end ChangeButton
	
	
	public void CheckDuration()						//works <3
	{
		
		if(nowPlaying)
		{
			try{
				if(!musicThread.isAlive())
				{
					Stop();	
					//automaticly go to the next one;
					
					@SuppressWarnings("unchecked")
					Iterator<Entry<String, String>> it = playlist.mainList.get(Playlist.name).entrySet().iterator();
					while(it.hasNext())
					{
						Entry<String, String> curr = it.next();
					
						if(curr.getKey().equals(song))
						{	
							ClickableLabel.songName = it.next().getKey();
							break;
						}
					}
					
				}
			}
			catch(Exception e)
			{
						System.out.println("damn");
			}
		}
	
	}
	
	
	
	
}  <file_sep>/README.md
# Nebula
####alpha(centauri)
__________________

Nebula is a music player (currently only supporting mp3 file format) written entirely in java.
Consequently, it is cross-platform and will run on any JRE equipped system.
The GUI is written in awt and swing. 
For the decoder I am using the [JLayer Javazoom](http://www.javazoom.net/javalayer/javalayer.html) library.
This is still very much of a work in progress.

__________________
####Planned features:

* Support for other codecs
 * flac
 * wav
 * m4a
* Make the UI more liquid
* Redesign the horrid looking control panel
* sync files from the entire disk

__________________
####Screenshots

![picture alt](https://raw.githubusercontent.com/Dauta/Nebula/master/nebula_screen.jpg)


 





