Search code examples
javawavvlcj

Stuttering in java vlcj playback of expanding wav files


I'm using vlcj in java to playback wav files, that are being expanded by other services. My problem is the following:

when I open an audio file the player knows that the duration is x sec. If it reaches the end it has to reopen (player.controls().start()) the file to know the expanded duration. This restart causes a micro stutter in playback (like 0.1 second) but it can be heard, and if the expanding process is slow than the stuttering can happen like every 2 seconds.

I have no way to modify the underlying architecture, so i can not use streaming.

The main issue as I see after hours of research is that vlcj do not provide a way to manually update the duration (that i can calculate by the file size) of the played audio file (it probably loads it to memory on open i guess).

Does somebody tried to implement this kind of playback with success?


Solution

  • After extended research in the topic I concluded that stutterless playback with the above described setup cannot be achieved. It can be optimized greatly, but will never be perfect. The root of the problem is that the length (duration) of the played wav file cannot be set manually, thus reload is a must for rescan.

    My solution for this was to implement a live555 RTSP streaming server between the storage and the client. The vlcj player connects to the rtsp stream and plays the (expanding) file seamlessly. The drawbacks are that the playtime needs specific handling, and has less performance (slower response to events).