javavlcvlcj

Vlcj change video background color


I'm creating a narrative application in which I need to play videos.

When playing a media with MediaPlayer.playMedia(Media media). In order to avoid the black background I wait the wait for the playing event before showing the media player.

        player.addMediaPlayerEventListener(new MediaPlayerEventAdapter() {
            
            @Override
            public void playing(MediaPlayer mediaPlayer) {
                showVideo();
            }
        }

The problem is that this event is triggered before the video actually starts playing, so it still displays black for a little while before.

How can I find a way around this? Thanks


Solution

  • I don't know for certain, but you could try some other event listener methods - perhaps the videoOutput, elementaryStreamAdded or elementaryStreamSelected (and check the stream type parameter was video), or maybe wait for the very first positionChanged event (whilst not ideal, it might work well enough for your use case).