Coucou les amis,

Après avoir pas mal farfouillé, je n'arrive pas à intégrer un lecteur VLCJ dans un JPanel. §
Voici le code que j'utilise :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 
public class RaspberryControler extends JFrame 
{
 
	       /*Have to declare it in order to use vlcj*/
	       private EmbeddedMediaPlayerComponent mediaPlayerComponent;
 
                public RaspberryControler(String host){
		     this.host = host;
		    controler = new Controler(this);  
	  	    initComponents();
	        }
 
             private void createWebcamPanel(){  
 
	        /*Get the VLC Libraries*/
	        NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "C:/VLC/VideoLAN/VLC");
	        Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
 
		mediaPlayerComponent = new EmbeddedMediaPlayerComponent(); 
 
		/*Create components*/
		liveStream = new JLabel("Live Stream"); 
 
		/*Set parameters of the components*/
		liveStream.setPreferredSize(new Dimension(200, 30));
		liveStream.setHorizontalAlignment(SwingConstants.CENTER);
 
		/*Set the layout*/
		webcamPanel = new JPanel();
		webcamPanel.setLayout(new BorderLayout()); 
		webcamPanel.setPreferredSize(new Dimension(550, 480));
		webcamPanel.setBorder(BorderFactory.createLineBorder(Color.RED));
 
		/*Place the components*/
		webcamPanel.setVisible(true);
		webcamPanel.add(liveStream, BorderLayout.NORTH);
		webcamPanel.add(mediaPlayerComponent, BorderLayout.CENTER);
		try{
			mediaPlayerComponent.getMediaPlayer().playMedia("http://127.0.0.1:8989/movie");
		}catch(IllegalStateException e){
			System.out.println(e.toString());
		}
	}
 
 
 
 
}
L'erreur que j'obtiens est la suivante : java.lang.IllegalStateException: The video surface component must be displayable

Auriez vous une idée d'ou cela pourrait éventuellement venir ?

Excellente soirée,

Mornor.

EDIT : Finalement trouvé, il faut que tout les components soient placés dans la JFrame, de faire un setVisible(true) à la fin et de créer une méthode charger de lire le média (qui sera appellée quand tout les composants seront dans la JFrame)