Embedding VLCJ in JPanel

后端 未结 3 958
[愿得一人]
[愿得一人] 2020-12-06 18:57

I have read this SO thread and when I have tried to use the code with some changes, I\'m getting just a black window, can some one tell me what I\'m doing wrong here, I have

相关标签:
3条回答
  • 2020-12-06 19:35

    When I change the video url (also called MRL as Media Ressource Locator) to this : C:\\MyVideo.mp4 I got the video in the window.

    this discussion has helped me.

    0 讨论(0)
  • 2020-12-06 19:37
    //Creating the canvas and adding it to the panel :
    canvas = new WindowsCanvas();
    canvas.setSize(700, 500);
    panel.add(canvas);
    
    0 讨论(0)
  • 2020-12-06 19:44

    I did something like this

    EmbeddedMediaPlayerComponent mediaPlayerComponent = new EmbeddedMediaPlayerComponent();
            EmbeddedMediaPlayer embeddedMediaPlayer = mediaPlayerComponent.getMediaPlayer();
    
            Canvas videoSurface = new Canvas();
            videoSurface.setBackground(Color.black);
            videoSurface.setSize(800, 600);
    
            List<String> vlcArgs = new ArrayList<String>();
    
            vlcArgs.add("--no-plugins-cache");
            vlcArgs.add("--no-video-title-show");
            vlcArgs.add("--no-snapshot-preview");
    
            MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory(vlcArgs.toArray(new String[vlcArgs.size()]));
            mediaPlayerFactory.setUserAgent("vlcj test player");
            embeddedMediaPlayer.setVideoSurface(mediaPlayerFactory.newVideoSurface(videoSurface));
            embeddedMediaPlayer.setPlaySubItems(true);
    
            final PlayerControlsPanel controlsPanel = new PlayerControlsPanel(embeddedMediaPlayer);
            PlayerVideoAdjustPanel videoAdjustPanel = new PlayerVideoAdjustPanel(embeddedMediaPlayer);
    
    //            mediaPlayerComponent.getMediaPlayer().playMedia(Constant.PATH_ROOT + Constant.PATH_MEDIA + "tmp.mp4");
            JFrame mainFrame = new JFrame();
            mainFrame.setLayout(new BorderLayout());
            mainFrame.setBackground(Color.black);
            mainFrame.add(videoSurface, BorderLayout.CENTER);
            mainFrame.add(controlsPanel, BorderLayout.SOUTH);
            mainFrame.add(videoAdjustPanel, BorderLayout.EAST);
    
            //create a button which will hide the panel when clicked.
            mainFrame.pack();
            mainFrame.setVisible(true);
    
            embeddedMediaPlayer.playMedia("tmp.mp4");
    
    0 讨论(0)
提交回复
热议问题