简体   繁体   中英

Error while adding embedded media Player component to JPanel

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)


在播放媒体之前,您必须使帧可见。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM