1 /*****************************************************************************
2 * VlcClient.java: Sample Swing player
3 *****************************************************************************
4 * Copyright (C) 1998-2006 the VideoLAN team
6 * Created on 28-feb-2006
8 * $Id: AudioIntf.java 8 2006-02-28 12:03:47Z little $
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.Frame;
27 import java.awt.event.WindowAdapter;
28 import java.awt.event.WindowEvent;
30 import org.videolan.jvlc.JVLCPanel;
31 import org.videolan.jvlc.JVLC;
32 import org.videolan.jvlc.VLCException;
34 class VLCPlayerFrame extends Frame {
35 public VLCPlayerFrame() {
39 private void initComponents() {
41 java.awt.GridBagConstraints gridBagConstraints;
43 fullScreenButton = new javax.swing.JButton();
44 jTextField1 = new javax.swing.JTextField();
45 setButton = new javax.swing.JButton();
46 pauseButton = new javax.swing.JButton();
47 stopButton = new javax.swing.JButton();
49 jvcc = new JVLCPanel();
50 jvlc = jvcc.getJVLCObject();
52 setLayout(new java.awt.GridBagLayout());
54 gridBagConstraints = new java.awt.GridBagConstraints();
55 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.CENTER;
56 gridBagConstraints.gridx = 0;
57 gridBagConstraints.gridy = 0;
58 add( jvcc , gridBagConstraints);
60 fullScreenButton.setText("FullScreen");
61 fullScreenButton.addActionListener(new java.awt.event.ActionListener() {
62 public void actionPerformed(java.awt.event.ActionEvent evt) {
63 fullScreenButtonActionPerformed(evt);
67 gridBagConstraints = new java.awt.GridBagConstraints();
68 gridBagConstraints.gridx = 0;
69 gridBagConstraints.gridy = 2;
70 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
71 add( fullScreenButton, gridBagConstraints);
74 jTextField1.setText("file://a.avi");
75 gridBagConstraints = new java.awt.GridBagConstraints();
76 gridBagConstraints.gridx = 0;
77 gridBagConstraints.gridy = 1;
78 gridBagConstraints.gridwidth = 2;
79 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
80 add(jTextField1, gridBagConstraints);
83 setButton.setText("Set item");
84 setButton.addActionListener(new java.awt.event.ActionListener() {
85 public void actionPerformed(java.awt.event.ActionEvent evt) {
86 setButtonActionPerformed(evt);
89 gridBagConstraints = new java.awt.GridBagConstraints();
90 gridBagConstraints.gridx = 2;
91 gridBagConstraints.gridy = 1;
92 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
93 add(setButton, gridBagConstraints);
96 pauseButton.setText("Play/Pause");
97 pauseButton.addActionListener(new java.awt.event.ActionListener() {
98 public void actionPerformed(java.awt.event.ActionEvent evt) {
99 pauseButtonActionPerformed(evt);
102 gridBagConstraints = new java.awt.GridBagConstraints();
103 gridBagConstraints.gridx = 1;
104 gridBagConstraints.gridy = 2;
105 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
106 add(pauseButton, gridBagConstraints);
108 stopButton.setText("Stop");
109 stopButton.addActionListener(new java.awt.event.ActionListener() {
110 public void actionPerformed(java.awt.event.ActionEvent evt) {
111 stopButtonActionPerformed(evt);
114 gridBagConstraints = new java.awt.GridBagConstraints();
115 gridBagConstraints.gridx = 2;
116 gridBagConstraints.gridy = 2;
117 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
118 add(stopButton, gridBagConstraints);
126 private void stopButtonActionPerformed(java.awt.event.ActionEvent evt) {
128 //mci.stop(new Position(10000, PositionOrigin.ABSOLUTE, PositionKey.MEDIATIME));
129 jvlc.playlist.stop();
130 } catch (Exception e) {
135 private void pauseButtonActionPerformed(java.awt.event.ActionEvent evt) {
137 //System.out.println(mci.getMediaPosition(PositionOrigin.ABSOLUTE, PositionKey.BYTECOUNT));
138 jvlc.playlist.togglePause();
139 } catch (Exception e) {
144 private void setButtonActionPerformed(java.awt.event.ActionEvent evt) {
146 jvlc.playlist.add("file://a.avi", "a.avi");
147 jvlc.playlist.play(-1, null);
148 } catch (VLCException e) {
149 // TODO Auto-generated catch block
154 private void fullScreenButtonActionPerformed(java.awt.event.ActionEvent evt) {
158 private javax.swing.JButton setButton;
159 private javax.swing.JButton pauseButton;
160 private javax.swing.JButton stopButton;
161 private javax.swing.JButton fullScreenButton;
162 private javax.swing.JTextField jTextField1;
163 private JVLCPanel jvcc;
165 //MediaControlInstance mci;
170 public class VlcClient {
172 public static void main(String[] args) {
173 Frame f = new VLCPlayerFrame();
174 f.setBounds(0, 0, 500, 500);
175 f.addWindowListener( new WindowAdapter() {
176 public void windowClosing(WindowEvent ev) {