Trying to embed vlcj media player in a WindowsCanvas inside a JPanel

前端 未结 1 1778
无人共我
无人共我 2020-12-21 02:55

I\'m trying to play a video using vlcj inside a JPanel but it doesn\'t work for me. The message exception I am getting is \"java.lang.IllegalStateException: The video surfac

相关标签:
1条回答
  • 2020-12-21 03:07

    You're trying to play the media before the frame containing the canvas has been set to be visible. You'll need to put the playMedia() call in a separate method, and call it after the entire frame has been created and set as visible.

    EDIT:

    If you still want it to play straight off, just call the relevant method after you've created and made your frame visible:

    MyJFrame frame = new MyJFrame();
    frame.setVisible(true);
    frame.startPlaying();
    

    ...obviously you'll need to define startPlaying() on MyJFrame, but then it should start playing straight off. you just need to set the frame visible first.

    0 讨论(0)
提交回复
热议问题