javafx vlcj video freezes after few seconds while audio keeps playing

86 Views Asked by At

I am making a javafx media player using vlcj.

There is my DMediaPlayer.java class that creates the vlcj media player and returns an ImageView which displays the video.

and here is my PlayerView.java this class displays the video.

public class PlayerView extends BorderPane {

    private MenuBar menuBar;
    private VideoControlPanel controlPanel;
    private Drawer drawer;

    private IconsProvider icons;
    private MediaPlayerInterface mediaPlayer;
    private ImageView mediaView;
    private StackPane playerHolder;
    private ImageView view;


    public PlayerView() {
        view = new ImageView();
        icons = new IconsProvider();
        menuBar = new MenuBar(icons);
        setTop(menuBar);

        playerHolder = new StackPane();
        playerHolder.setAlignment(Pos.TOP_LEFT);
        setCenter(playerHolder);


        mediaPlayer = new DMediaPlayer();
        mediaView = mediaPlayer.getMediaView();
        playerHolder.getChildren().add(mediaView);
        try {
            mediaPlayer.load("/home/doruk/Downloads/Video/movie.mkv");
        } catch (FileNotFoundException e) {
            System.out.println(e.toString());
        }

        mediaPlayer.play();

        playerHolder.getChildren().add(drawer);

 
    }
}

The problem is the video plays as expected, but after few seconds, the ImageView only displays the single image, its like the video is paused. but the audio keeps on playing.

I thought the issue was due to ImageView being garbage collected as if I initially when the mediaplayer was called as follow:

DMediaPlayer player = new DMediaPlayer()
player.play()

inside the PlayerView class, there would be following errors:

JNA: callback object has been garbage collected
JNA: callback object has been garbage collected
JNA: callback object has been garbage collected
malloc(): unaligned tcache chunk detected

and so I created the the ImageView in the same PlayerView class and passed the reference to the DMediaPlayer so that it can play the video in it, but that does not work either.

0

There are 0 best solutions below