1 /*****************************************************************************
2 * VlcClient.java: Sample Swing player
3 *****************************************************************************
4 * Copyright (C) 1998-2006 the VideoLAN team
6 * Created on 28-feb-2006
10 * This program is free software; you can redistribute it
11 * and/or modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2 of the
13 * License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public
21 * License along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
26 import java.awt.Canvas;
27 import java.awt.Frame;
28 import java.awt.event.WindowAdapter;
29 import java.awt.event.WindowEvent;
31 import javax.swing.JPanel;
33 import org.videolan.jvlc.JVLC;
34 import org.videolan.jvlc.Playlist;
35 import org.videolan.jvlc.VLCException;
38 class VLCPlayerFrame extends Frame
41 private Playlist playlist;
43 public Canvas jvcanvas;
45 public VLCPlayerFrame()
50 private void initComponents()
53 java.awt.GridBagConstraints gridBagConstraints;
55 fullScreenButton = new javax.swing.JButton();
56 jTextField1 = new javax.swing.JTextField();
57 setButton = new javax.swing.JButton();
58 pauseButton = new javax.swing.JButton();
59 stopButton = new javax.swing.JButton();
62 jvcanvas = new java.awt.Canvas();
63 jvcanvas.setSize(200, 200);
68 playlist = new Playlist(jvlc);
70 setLayout(new java.awt.GridBagLayout());
72 gridBagConstraints = new java.awt.GridBagConstraints();
73 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.CENTER;
74 gridBagConstraints.gridx = 0;
75 gridBagConstraints.gridy = 0;
76 add(jvcc, gridBagConstraints);
78 fullScreenButton.setText("FullScreen");
79 fullScreenButton.addActionListener(new java.awt.event.ActionListener()
82 public void actionPerformed(java.awt.event.ActionEvent evt)
84 fullScreenButtonActionPerformed(evt);
88 gridBagConstraints = new java.awt.GridBagConstraints();
89 gridBagConstraints.gridx = 0;
90 gridBagConstraints.gridy = 2;
91 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
92 add(fullScreenButton, gridBagConstraints);
94 jTextField1.setText("file://a.avi");
95 gridBagConstraints = new java.awt.GridBagConstraints();
96 gridBagConstraints.gridx = 0;
97 gridBagConstraints.gridy = 1;
98 gridBagConstraints.gridwidth = 2;
99 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
100 add(jTextField1, gridBagConstraints);
102 setButton.setText("Set item");
103 setButton.addActionListener(new java.awt.event.ActionListener()
106 public void actionPerformed(java.awt.event.ActionEvent evt)
108 setButtonActionPerformed(evt);
111 gridBagConstraints = new java.awt.GridBagConstraints();
112 gridBagConstraints.gridx = 2;
113 gridBagConstraints.gridy = 1;
114 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
115 add(setButton, gridBagConstraints);
117 pauseButton.setText("Play/Pause");
118 pauseButton.addActionListener(new java.awt.event.ActionListener()
121 public void actionPerformed(java.awt.event.ActionEvent evt)
123 pauseButtonActionPerformed(evt);
126 gridBagConstraints = new java.awt.GridBagConstraints();
127 gridBagConstraints.gridx = 1;
128 gridBagConstraints.gridy = 2;
129 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
130 add(pauseButton, gridBagConstraints);
132 stopButton.setText("Stop");
133 stopButton.addActionListener(new java.awt.event.ActionListener()
136 public void actionPerformed(java.awt.event.ActionEvent evt)
138 stopButtonActionPerformed(evt);
141 gridBagConstraints = new java.awt.GridBagConstraints();
142 gridBagConstraints.gridx = 2;
143 gridBagConstraints.gridy = 2;
144 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
145 add(stopButton, gridBagConstraints);
151 private void stopButtonActionPerformed(java.awt.event.ActionEvent evt)
163 private void pauseButtonActionPerformed(java.awt.event.ActionEvent evt)
167 playlist.togglePause();
175 private void setButtonActionPerformed(java.awt.event.ActionEvent evt)
179 jvlc.setVideoOutput(jvcanvas);
180 playlist.add(jTextField1.getText(), "a.avi");
183 catch (VLCException e)
185 // TODO Auto-generated catch block
190 private void fullScreenButtonActionPerformed(java.awt.event.ActionEvent evt)
192 // jvlc.fullScreen();
195 private javax.swing.JButton setButton;
197 private javax.swing.JButton pauseButton;
199 private javax.swing.JButton stopButton;
201 private javax.swing.JButton fullScreenButton;
203 private javax.swing.JTextField jTextField1;
208 // MediaControlInstance mci;
213 public class VlcClient
216 public static void main(String[] args)
218 Frame f = new VLCPlayerFrame();
219 f.setBounds(0, 0, 500, 500);
220 f.addWindowListener(new WindowAdapter()
224 public void windowClosing(WindowEvent ev)