1

I tried this code to display a video on simple jframe:

package com.company;

import javax.swing.*;
import java.awt.*;

import uk.co.caprica.vlcj.player.component.EmbeddedMediaPlayerComponent;

public class Main {

    static EmbeddedMediaPlayerComponent myMedia = new EmbeddedMediaPlayerComponent();

    public static void main(String[] args) {
        JFrame j = new JFrame("Stream player");

        JPanel jp = new JPanel();
        jp.setBounds(0, 0, 700, 300);
        jp.setLayout(null);

        myMedia.mediaPlayer().media().start("C:\\Users\\cikko\\Downloads\\Video\\144.mp4");
        myMedia.setBounds(0, 0, 700, 280);

        jp.setBackground(Color.BLACK);
        jp.add(myMedia);

        j.add(jp);

        j.setSize(700, 300);
        j.setLayout(null);
        j.setVisible(true);
    }

}

but it gives error. I tried change jpanel layout but it didn't work either. How To Can I solve it? Thanks

Exception in thread "main" java.lang.IllegalStateException: The video surface component must be displayable
    at uk.co.caprica.vlcj.player.embedded.videosurface.ComponentVideoSurface.attach(ComponentVideoSurface.java:66)


1 Answer 1

1

You must make your frame visible before you play your media.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.