private void registerListeners() {
        // Add volume listener.
        mediaPlayer.addMediaPlayerEventListener(new MediaPlayerEventAdapter() {
            @Override
            public void playing(MediaPlayer mediaPlayer) {
                updateVolume(mediaPlayer.getVolume());
            }
        });

        // Add position slider listener
        positionSlider.addMouseListener(new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent e) {
                if(mediaPlayer.isPlaying()) {
                    mousePressedPlaying = true;
                    mediaPlayer.pause();
                }
                else {
                    mousePressedPlaying = false;
                }
                setSliderBasedPosition();
            }

            @Override
            public void mouseReleased(MouseEvent e) {
                setSliderBasedPosition();
                updateUIState();
            }
        });

        // add listener to rewind button
        rewindButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                skip(-SKIP_TIME_MS);
            }
        });

        // add listener to stop button
        stopButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                mediaPlayer.stop();
                playButton.setIcon(img3);
            }
        });

        // add listener to play button
        playButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (playButton.getIcon()==img3){
                    mediaPlayer.play();
                    playButton.setIcon(img2);

                }
                else {   
                    playButton.setIcon(img3);
                    //VideoPlayer.setPause();
                    mediaPlayer.pause();
                }
            }
        });

        // Add listener to fast forward button.
        fastForwardButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                skip(SKIP_TIME_MS);
            }
        });

        // Add listener to volume slider.
        volumeSlider.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                JSlider source = (JSlider)e.getSource();
                //        if(!source.getValueIsAdjusting()) {
                mediaPlayer.setVolume(source.getValue());
                //        }
            }
        });

        // Add listener for toggling full screen (NOTE fullscreen not working currently.)
        fullScreenButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                mediaPlayer.toggleFullScreen();
            }
        });

        // Add listener for looping.
        loop.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (loopOn==false){
                    loopOn=true;
                    mediaPlayer.setRepeat(true);
                    loopLabel.setText("Loop On");
                }
                else{
                    loopOn=false;
                    mediaPlayer.setRepeat(false);
                    loopLabel.setText("Loop Off");
                }
            }
        });
    }