]> git.sesse.net Git - vlc/blob - bindings/java/VlcClient.java
Java bindings by Filippo Carone.
[vlc] / bindings / java / VlcClient.java
1 import org.videolan.jvlc.*;
2
3 import java.awt.*;
4 import java.awt.event.*;
5
6 class VLCPlayerFrame  extends Frame {
7     public VLCPlayerFrame() {
8         initComponents();
9     }
10     
11     private void initComponents() {
12         java.awt.GridBagConstraints gridBagConstraints; 
13
14         fullScreenButton = new javax.swing.JButton();
15         jTextField1 = new javax.swing.JTextField();
16         setButton = new javax.swing.JButton();
17         pauseButton = new javax.swing.JButton();
18         stopButton = new javax.swing.JButton();
19
20 //      jPanel = new javax.swing.JPanel();
21         jvcc  = new JVLCCanvas();
22         jvlc = jvcc.getJVLCObject();
23 //      jPanel.add( jvcc );
24         add( jvcc );
25
26         // FIXME: Does not work with GridBagLayout
27         setLayout(new java.awt.GridLayout(3,2));
28
29         gridBagConstraints = new java.awt.GridBagConstraints();
30         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
31 //        add( jPanel , gridBagConstraints);
32
33
34         fullScreenButton.setText("FullScreen");
35         fullScreenButton.addActionListener(new java.awt.event.ActionListener() {
36             public void actionPerformed(java.awt.event.ActionEvent evt) {
37                 fullScreenButtonActionPerformed(evt);
38             }
39         });
40
41         gridBagConstraints = new java.awt.GridBagConstraints();
42         gridBagConstraints.gridx = 0;
43         gridBagConstraints.gridy = 2;
44         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
45         add( fullScreenButton, gridBagConstraints);
46
47
48         jTextField1.setText("URL");
49         gridBagConstraints = new java.awt.GridBagConstraints();
50         gridBagConstraints.gridx = 0;
51         gridBagConstraints.gridy = 1;
52         gridBagConstraints.gridwidth = 2;
53         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
54         add(jTextField1, gridBagConstraints);
55
56
57         setButton.setText("Set item");
58         setButton.addActionListener(new java.awt.event.ActionListener() {
59             public void actionPerformed(java.awt.event.ActionEvent evt) {
60                 setButtonActionPerformed(evt);
61             }
62         });
63         gridBagConstraints = new java.awt.GridBagConstraints();
64         gridBagConstraints.gridx = 2;
65         gridBagConstraints.gridy = 1;
66         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
67         add(setButton, gridBagConstraints);
68
69
70         pauseButton.setText("Play/Pause");
71         pauseButton.addActionListener(new java.awt.event.ActionListener() {
72             public void actionPerformed(java.awt.event.ActionEvent evt) {
73                 pauseButtonActionPerformed(evt);
74             }
75         });
76         gridBagConstraints = new java.awt.GridBagConstraints();
77         gridBagConstraints.gridx = 1;
78         gridBagConstraints.gridy = 2;
79         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
80         add(pauseButton, gridBagConstraints);
81
82         stopButton.setText("Stop");
83         stopButton.addActionListener(new java.awt.event.ActionListener() {
84             public void actionPerformed(java.awt.event.ActionEvent evt) {
85                 stopButtonActionPerformed(evt);
86             }
87         });
88         gridBagConstraints = new java.awt.GridBagConstraints();
89         gridBagConstraints.gridx = 2;
90         gridBagConstraints.gridy = 2;
91         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
92         add(stopButton, gridBagConstraints);
93
94         pack();
95     }
96
97     private void stopButtonActionPerformed(java.awt.event.ActionEvent evt) {
98         jvlc.stop();
99     }
100
101     private void pauseButtonActionPerformed(java.awt.event.ActionEvent evt) {
102         jvlc.pause();
103     }
104
105     private void setButtonActionPerformed(java.awt.event.ActionEvent evt) {
106         jvlc.stop();
107         jvlc.playlistClear();
108         jvlc.addTarget( jTextField1.getText(), null, 1, -666 );
109         jvlc.play();
110     }
111
112     private void fullScreenButtonActionPerformed(java.awt.event.ActionEvent evt) {
113         jvlc.fullScreen();
114     }
115     
116     private javax.swing.JButton setButton;
117     private javax.swing.JButton pauseButton;
118     private javax.swing.JButton stopButton;
119     private javax.swing.JButton fullScreenButton;
120     private javax.swing.JTextField jTextField1;
121     private javax.swing.JPanel jPanel;
122     private JVLCCanvas jvcc;
123     public JVLC jvlc;
124 }
125
126
127 public class VlcClient {
128
129     public static void main(String[] args) {
130     Frame f = new  VLCPlayerFrame();
131     f.setBounds(0, 0, 500, 500);
132     f.addWindowListener( new WindowAdapter() {
133         public void windowClosing(WindowEvent ev) {
134             System.exit(0);
135         }   
136     } );    
137     f.setVisible(true);
138    }
139 }