Changed some gst threading behaviour to prevent unescaped thread interruptions.
This commit is contained in:
parent
337ed9c076
commit
53e4f47029
@ -22,7 +22,7 @@ public class GStreamerPlayer implements IPlayer{
|
||||
|
||||
private final PlayBin2 playBin;
|
||||
|
||||
private InternalThread internalThread;
|
||||
private final InternalThread internalThread = new InternalThread();
|
||||
private Thread thread;
|
||||
private Song currentSong;
|
||||
private final PlayerCallbackInterface callbackInterface;
|
||||
@ -62,9 +62,9 @@ public class GStreamerPlayer implements IPlayer{
|
||||
playSong(currentSong);
|
||||
else
|
||||
playSong(playlist.getNext(currentSong));
|
||||
} catch (InterruptedException | StartPlayingException e) {
|
||||
} catch (StartPlayingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (InterruptedException ignored){}
|
||||
});
|
||||
callbackThing.start();
|
||||
});
|
||||
@ -108,8 +108,10 @@ public class GStreamerPlayer implements IPlayer{
|
||||
* @throws StartPlayingException
|
||||
*/
|
||||
private void playSong(Song inputSong) throws StartPlayingException {
|
||||
if (playBin.getState() == State.PLAYING)
|
||||
if (playBin.getState() == State.PLAYING) {
|
||||
internalThread.stop();
|
||||
stop();
|
||||
}
|
||||
if(playBin.getState() == State.PAUSED && inputSong == currentSong) {
|
||||
resume();
|
||||
return;
|
||||
@ -125,11 +127,10 @@ public class GStreamerPlayer implements IPlayer{
|
||||
return;
|
||||
}
|
||||
playBin.setURI(songFile.toURI());
|
||||
internalThread = new InternalThread();
|
||||
thread = new Thread(internalThread, "GSTThread");
|
||||
setVolume(currentVolume);
|
||||
playBin.play();
|
||||
if(playBin.getState() == State.PLAYING) {
|
||||
thread = new Thread(internalThread, "GSTThread");
|
||||
thread.start();
|
||||
while (true) {
|
||||
if (playBin.queryDuration().getSeconds() > 0 || playBin.queryDuration().getNanoSeconds() > 0) break;
|
||||
|
Loading…
Reference in New Issue
Block a user