|
|
@ -95,6 +95,11 @@ public class MusicHandler implements AudioSendHandler, Closeable |
|
|
|
currentSong.delete(); |
|
|
|
currentSong.delete(); |
|
|
|
currentSong = null; |
|
|
|
currentSong = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (player != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
player.close(); |
|
|
|
|
|
|
|
player = null; |
|
|
|
|
|
|
|
} |
|
|
|
currentSong = queueManager.nextSongNeeded(); |
|
|
|
currentSong = queueManager.nextSongNeeded(); |
|
|
|
if (nowPlayingConsumer != null) |
|
|
|
if (nowPlayingConsumer != null) |
|
|
|
nowPlayingConsumer.accept(currentSong); |
|
|
|
nowPlayingConsumer.accept(currentSong); |
|
|
@ -179,57 +184,6 @@ public class MusicHandler implements AudioSendHandler, Closeable |
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// private void fillBuffer(boolean canSkip)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// // use what we have in our buffer to send audio as PCM
|
|
|
|
|
|
|
|
// while (audioBuffer.getCurrentNumberOfBytes() < DESIRED_BUFFER_SIZE)
|
|
|
|
|
|
|
|
// if (!readData())
|
|
|
|
|
|
|
|
// if (!canSkip || !nextSong())
|
|
|
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// private boolean readData()
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// if (din == null)
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
// try
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// // if (din.available() == 0)
|
|
|
|
|
|
|
|
// // return false;
|
|
|
|
|
|
|
|
// int bytesToRead = DESIRED_BUFFER_SIZE - audioBuffer.getCurrentNumberOfBytes();
|
|
|
|
|
|
|
|
// int space = audioBuffer.getSpace();
|
|
|
|
|
|
|
|
// if (din.available() > 0 && din.available() < bytesToRead)
|
|
|
|
|
|
|
|
// bytesToRead = din.available();
|
|
|
|
|
|
|
|
// if (bytesToRead > space)
|
|
|
|
|
|
|
|
// bytesToRead = space;
|
|
|
|
|
|
|
|
// if (bytesToRead == 0)
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
// byte[] bytes = new byte[bytesToRead];
|
|
|
|
|
|
|
|
// // byte[] bytes = din.readNBytes(bytesToRead);
|
|
|
|
|
|
|
|
// int read = din.read(bytes);
|
|
|
|
|
|
|
|
//// System.out.println("Wanted: " + byteCount + " Space:" + space + " Available: " + din.available() + " To read: " + bytesToRead + " Read: " + read);
|
|
|
|
|
|
|
|
// if (read < 0)
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
//// queue.add(bytes);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// audioBuffer.add(bytes, 0, read);
|
|
|
|
|
|
|
|
// } catch (IOException ex)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
// } catch (ArrayIndexOutOfBoundsException ex)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// if (!arrayErr)
|
|
|
|
|
|
|
|
// arrayErr = true;
|
|
|
|
|
|
|
|
// else
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return true;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
public Song getCurrentSong() |
|
|
|
public Song getCurrentSong() |
|
|
|
{ |
|
|
|
{ |
|
|
|
return currentSong; |
|
|
|
return currentSong; |
|
|
|