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

Multiple files playing issue #54

Open
Georgieeeee opened this issue Dec 13, 2019 · 11 comments · Fixed by sunny-chung/java-stream-player#1
Open

Multiple files playing issue #54

Georgieeeee opened this issue Dec 13, 2019 · 11 comments · Fixed by sunny-chung/java-stream-player#1
Assignees
Labels
bug improvement Refactorings and internal structure improvements

Comments

@Georgieeeee
Copy link

Georgieeeee commented Dec 13, 2019

If multiple audio files are opened and played, they play one after each other, but it freezes the program where actions like .stop(), etc can't be used, which is a problem as now all files that are queued can't be stopped. Is there a way to fix this?

@goxr3plus
Copy link
Owner

Yes that's a problem a never managed to solve until now, playing multiple songs in row. It's a bug :(

@goxr3plus
Copy link
Owner

I am actually using an external Thread to call '.stop()' in XR3Player.

@Georgieeeee
Copy link
Author

Georgieeeee commented Dec 13, 2019

If it's playing on a thread, did you try to .join() the threads so that they are all combined so when new files are added to the thread, so that they can all be stopped at the same time

If the SteamplayerLister can trigger the files to open and play within the Status stopped then it will work, but the problem is that it's not possible to play files from within that

@goxr3plus
Copy link
Owner

I have to find a solution on that , now what i do is open and play a song in one Thread , i open one other thread which calls .stop() which is blocking until the .stop() returns , then inside that Thread i call again .open() and .play() to play the new song and it exits.

.play() is using it's own Thread to play the song.It's just the .stop() that is blocking the Thread that is called from.

The problem is we need a mechanism to know when the previous song ended which i have not implemented .

@goxr3plus goxr3plus self-assigned this Dec 18, 2019
@goxr3plus goxr3plus added bug improvement Refactorings and internal structure improvements labels Dec 18, 2019
@AObuchow
Copy link
Contributor

I've now run into this issue in my own program. Will have to look into it cause it's a blocker for my use case :P

@goxr3plus
Copy link
Owner

goxr3plus commented Apr 15, 2020 via email

@AObuchow
Copy link
Contributor

Mmm i have solved that in the past in XR3Player. I was using JavaFX and for each player i had a Thread Service. Everytime i want to stop a song i was calling stop from a Thread different than the main thread so it doesn't freezes. O gosh i have solved all that in XR3Player i hope there is not bugs in new Stream-Player library version.

Thanks for the reply @goxr3plus :)

In my case, I only have one player (StreamPlayer) instance. It's being instantiated with a SingleThreadExecutor (such as here). I don't know if this is relevant to your solution however, just wanted to give more details.

To give more context of my application, the UI presents the user with a list of audio files. When an audio file is hovered on (by pressing up/down on the arrow keys), the song is played. When the user presses the up or down arrow key several times in a row, the UI freezes up and each song traversed is played a bit before changing to the next.

You mentioned that you were calling stop from a different thread than the main thread so that it doesn't freeze. I tried calling stop (and open + play) from a CompletableFuture.runAsync() which seems to prevent the UI from freezing up, but two issues arise when multiple stop/play attempts are made in quick succession:

  1. Sometimes a song won't start from the beginning, instead, it'll start at a later point in the song
  2. Certain sounds (that are less than 1 second long) don't seem to be able to be stopped and will be fully played before the next sound can be played

I'm not sure if you have any ideas on what could be going on in these two cases, but figured I'd mention it :)

Also I just checked out https://github.com/goxr3plus/XR3Player, it looks amazing :D I'll try to inspect how it works and compare it to my (much simpler) application :)

@goxr3plus
Copy link
Owner

goxr3plus commented Apr 16, 2020

Hm thank you very much for mentioning those problems, i think you will need to go into deeper investigation of how this library works then.

Do me one favor try the previous version, the 9.0.4 which had my old architecture and tell me if you face the same problem there. I have never tested the 10 version for multithreading issues, on the other side 9.0.4 is battle tested on XR3Player.

Hey on XR3Plager have a look at this class to see exactly how i do it :

https://github.com/goxr3plus/XR3Player/blob/master/src/main/java/com/goxr3plus/xr3player/controllers/xplayer/XPlayerController.java

Go on the method playSong line 2120.
This class has all the logic you need for the player. Please do some reverse engineer there i hope the method names help you.

I know you will have problem with the logger there but i just need to know if we introduced any bug with the version 10

@goxr3plus
Copy link
Owner

goxr3plus commented Apr 22, 2020

@AObuchow Tell me how it is going for you :)

I just had a look on XR3Player and had nostalgia , i might restart working it on Java 14 with the latest and greatest features and add some streaming services :)

@AObuchow
Copy link
Contributor

Hm thank you very much for mentioning those problems, i think you will need to go into deeper investigation of how this library works then.

Do me one favor try the previous version, the 9.0.4 which had my old architecture and tell me if you face the same problem there. I have never tested the 10 version for multithreading issues, on the other side 9.0.4 is battle tested on XR3Player.

Hey on XR3Plager have a look at this class to see exactly how i do it :

https://github.com/goxr3plus/XR3Player/blob/master/src/main/java/com/goxr3plus/xr3player/controllers/xplayer/XPlayerController.java

Go on the method playSong line 2120.
This class has all the logic you need for the player. Please do some reverse engineer there i hope the method names help you.

I know you will have problem with the logger there but i just need to know if we introduced any bug with the version 10

Thanks so much for giving me a reference point :) I’ll try it out when I have a moment, sorry for the delayed reply! I really appreciate the detailed response. It helps a lot :)

@AObuchow
Copy link
Contributor

@AObuchow Tell me how it is going for you :)

I just had a look on XR3Player and had nostalgia , i might restart working it on Java 14 with the latest and greatest features and add some streaming services :)

Things are going well! I just took a break from the asynchronous audio player bug and worked on other features of my audio-file manager :) I’ve also been dealing with another side project which needs to be completed by May 1st so that’s taking priority.

I promise I’ll get back to it though so I can follow up with you :)

As for continuing the development of XR3Player - YES!! I think that’s a great idea, it’s a really cool application and some of the Java 14 features look really nice to use (I’ve been meaning to try them out myself!)

Looking forward to it :)

sunny-chung added a commit to sunny-chung/java-stream-player that referenced this issue Oct 2, 2023
sunny-chung added a commit to sunny-chung/java-stream-player that referenced this issue Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug improvement Refactorings and internal structure improvements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants