@Override
	public void run()
	{
		int bytesRead = 0;
		
		while (true)
		{
			try
			{
				if (isPlaying == true)
				{
					if (line != null)
					{
						if (bytesRead == -1)
						{
							isPlaying = false;
							bytesRead = 0;
							inputStream.reset();
							
							line.drain();
							
							if (isLooping)
							{
								isPlaying = true;
							}
							
							continue;
						}
						
						bytesRead = inputStream.read(buffer, 0, buffer.length);
						
						if (bytesRead >= 0)
						{
							line.write(buffer, 0, bytesRead);
						}
					}
					else
					{
						//line is null
						Thread.sleep(17);
					}
				}
				else
				{
					//not playing
					Thread.sleep(17);
				}
			}
			catch (Exception e)
			{
				e.printStackTrace();
				isPlaying = false;
			}
		}
	}