Fixed volume resetting between songs.

This commit is contained in:
neviyn 2016-02-25 20:28:10 +00:00
parent 9ea708d20a
commit 962846f397

View File

@ -18,6 +18,7 @@ public class Player {
private Thread thread; private Thread thread;
private Song currentSong; private Song currentSong;
private PlayerCallbackInterface callbackInterface; private PlayerCallbackInterface callbackInterface;
private int currentVolume = 100;
/** /**
* Manages GStreamer based playback operations. * Manages GStreamer based playback operations.
@ -40,6 +41,7 @@ public class Player {
}); });
callbackThing.start(); callbackThing.start();
}); });
currentVolume = getVolume();
} }
/** /**
@ -62,6 +64,7 @@ public class Player {
playBin.setURI(songFile.toURI()); playBin.setURI(songFile.toURI());
internalThread = new InternalThread(); internalThread = new InternalThread();
thread = new Thread(internalThread); thread = new Thread(internalThread);
setVolume(currentVolume);
playBin.play(); playBin.play();
thread.start(); thread.start();
while (true) { while (true) {
@ -115,6 +118,7 @@ public class Player {
* @param volume New volume in percent. * @param volume New volume in percent.
*/ */
public void setVolume(int volume){ public void setVolume(int volume){
currentVolume = volume;
playBin.setVolumePercent(volume); playBin.setVolumePercent(volume);
} }