Open GDjkhp opened 3 years ago
Hello :), As for the play() i am not sure how i can make it faster.
How to get the song position please check the methods here.
If you want to have a deep look on how exactly use all the functions of this library you can check the code or XR3PLAYER :)
public static void playSong (File file){ try { // ----------------------Open the Media System.out.println("Opening ..."); streamPlayer.open(file);
// ---------------------- Play the Media
System.out.println("Starting to play ...");
streamPlayer.play();
} catch (StreamPlayerException e) {
e.printStackTrace();
}
}
is there a way to make this code to wait until the music starts playing at 00:00? just like in slick2d, which the code must first finish opening then if it was playing, it will continue executing next lines of code, also, i want a slick2d music implementation for StreamPlayer, is it possible?
edit: how to make the audio play at zero latency after running streamPlayer.play()?
I am not sure how to do the above if you can help please feel free to pull request :)
Maybe i can help for the question "how to make the code wait until the music starts playing at 00:00.
I would probably get the current position of the song if it is 00:01 i would continue the code. So basically i would have a thread waiting and fetching the audio position every second until it satisfies our condition.
I don't know about slick2d and as a saw it is not supported since 2015
:)
edit: how to make the audio play at zero latency after running streamPlayer.play()?
I don't know if this is possible because it has to buffer the input stream first and then play
ok i'll try the thread wait trick, also what i mean about slick2d, Slick2D Music class has zero latency, by loading the whole file once, then if you want to play the sound again, it will not load because you have loaded it before
Well that can crash the program imagine you load a 2 hours audio. Java Audio Clip class can be used for that but when i did used in the past the ram was going to the moooon, like Tesla stock :)
On Fri, Jan 8, 2021, 14:00 GDjkhp notifications@github.com wrote:
ok i'll try the thread wait trick, also what i mean about slick2d, Slick2D Music class has zero latency, by loading the whole file once, then if you want to play the sound again, it will not load because you have loaded it before
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/goxr3plus/Java-Spectrum-Analyser-Tutorials/issues/2#issuecomment-756719494, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE3OFQAUNSETNQQ24IQ2JGDSY3XXNANCNFSM4VUZF57A .
Even advanced program for DJ's like VirtualDj use Buffer. Can you upload a 2 hours clip on slick2d and tell me how much ram it uses? Probably i can make it like check the length of the song and use clip or buffer but the whole library has to be rewritten.
i think openal/slick2d doesn't load the file into the memory (ram), instead it just play the file directly from the hard drive, i noticed loading 20 music files will load within 5 mins, and the program just eats only hundred megabytes of ram
heres before running my game without loading the sounds
heres after loading a bunch of audio files on my game (which you can use anytime you want if you loaded it before)
how do i fix this?, also how do i get the current song position?