简体   繁体   中英

VLCJ-4: audio playback stops too early ("finished" event is fired before end of media)

After migrating my Java application from vlcj-3.12.1 to vlcj-4.8.2 I am observing that the finished() event is being fired approximately 2 seconds before the media has reached its end/full length/duration. This messes up my GUI as I have a media time display showing both elapsed and remaining time. So when it shows 2 seconds remaining now, it suddenly jumps down to 0 and it sounds like the last bit of the audio is being "cut off".

I have tried various media files and various audio formats with different bitrates (including VBR) - the result is identical in all cases. The following logfile snipplet shows that the length of the media is being correctly read when the playing() event is received ( 24 secs ). I am logging the timeChanged() events during playback. You can see that these events stop coming right before the media time reaches ~22 secs . Then the finished() event gets fired. No more timeChanged() events thereafter - the last 2 seconds of playback are missing.

Is this a bug in VLC or VLCJ which is targeted for an upcoming version or might I be doing something wrong? The issue did not occur with vlcj-3.12.1 and it also does not occur when playing the media with native VLC. I really don't want to downgrade again but this is kind of a let-down. I am running the latest VLC version 3.0.17.4 on Windows 10 with Java 17.0.5 .

Thanks in advance!

I have found the solution. The issue was related to the following VLC parameters that I passed to the MediaPlayerFactory:

--file-caching=2000
--network-caching=2000

It is exactly these 2 seconds that the media player skips playing at the end of the file. Not sure how this is related, maybe it's a bug. These settings haven't caused any trouble in previuos versions of VLC. I have removed caching for now and everything is back to normal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM