Search code examples
javaoverridingvlcj

Error when Overriding method from MediaPlayerEventAdapter VLCj


I am using an EmbeddedMediaPlayer object to read video files. What I want is to know when the video is done playing so I need an Event listener. The MediaPlayerEventListener and MediaPlayerEventAdapter have a finished() method. But when I try to override the method, the following error comes up:

The method finished(MediaPlayer) of type new MediaPlayerEventAdapter(){} must override or implement a supertype method.

Here is my piece of code:

private void registerListeners()
{
    mediaPlayer.addMediaPlayerEventListener(new MediaPlayerEventAdapter(){

        @Override
        public void finished(MediaPlayer mediaPlayer){
            avatarplayerappInstance.playDoneHandler();
        }

    });
}

Do you have any idea of how I can solve that issue ? Thanks a lot.


Solution

  • Usually this error is triggered when the arguments of the method are not matching the method definition ones.

    Here, MediaPlayer should be imported from the same package as MediaPlayerEventAdapter.

    Make sure you imported these:

    import uk.co.caprica.vlcj.player.MediaPlayer; 
    import uk.co.caprica.vlcj.player.MediaPlayerEventAdapter;