goxr3plus / java-stream-player

🌌Java Advanced Audio Controller Library (WAV, AU, AIFF, MP3, OGG VORBIS, FLAC, MONKEY's AUDIO and SPEEX audio formats )
GNU General Public License v3.0
147 stars 33 forks source link

How can the player be stopped? #15

Open HelgeStenstrom opened 5 years ago

HelgeStenstrom commented 5 years ago

I can't find how to stop the player. When I run Main.main(), it continues to sound after main() exits. The only way I have found is to call System.exit().

How can the player thread be stopped and/or joined?

goxr3plus commented 5 years ago

You can call https://github.com/goxr3plus/java-stream-player/blob/8bb2ad1cfc2bbdf2791a6677be3dcc2c6dd8054a/src/main/java/com/goxr3plus/streamplayer/stream/StreamPlayer.java#L598-L612

HelgeStenstrom commented 5 years ago

From what I could see, that stopped the playing, but the main application did not exit, because there was still a thread running.

I made some tests with stop() in my new main(). The playback stopped, but the application didn't exit if I didn't call System.exit(). Of course I didn't include this test in the pull request.

goxr3plus commented 5 years ago

Hm then it's the ExecutorService of Stream Player that doesn't exit immediately probably :)

HelgeStenstrom commented 5 years ago

I just realized that this issue is the same as #1 .