Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can the player be stopped? #15

Open
HelgeStenstrom opened this issue Aug 28, 2019 · 4 comments
Open

How can the player be stopped? #15

HelgeStenstrom opened this issue Aug 28, 2019 · 4 comments
Labels

Comments

@HelgeStenstrom
Copy link
Collaborator

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
Copy link
Owner

You can call

/**
* Stops the play back.<br>
* <p>
* Player Status = STOPPED.<br>
* Thread should free Audio resources.
*/
public void stop() {
if (status == Status.STOPPED)
return;
if (isPlaying())
pause();
status = Status.STOPPED;
// generateEvent(Status.STOPPED, getEncodedStreamPosition(), null);
logger.info("StreamPlayer stopPlayback() completed");
}

@HelgeStenstrom
Copy link
Collaborator Author

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
Copy link
Owner

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

@HelgeStenstrom
Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants