-import org.videolan.jvlc.*;
-
-import java.awt.*;
-import java.awt.event.*;
+/*****************************************************************************
+ * VlcClient.java: Sample Swing player
+ *****************************************************************************
+ * Copyright (C) 1998-2006 the VideoLAN team
+ *
+ * Created on 28-feb-2006
+ *
+ * $Id: AudioIntf.java 8 2006-02-28 12:03:47Z little $
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+import java.awt.Frame;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import org.videolan.jvlc.JVLCPanel;
+import org.videolan.jvlc.JVLC;
+import org.videolan.jvlc.VLCException;
class VLCPlayerFrame extends Frame {
public VLCPlayerFrame() {
}
private void initComponents() {
- java.awt.GridBagConstraints gridBagConstraints;
- fullScreenButton = new javax.swing.JButton();
- jTextField1 = new javax.swing.JTextField();
- setButton = new javax.swing.JButton();
- pauseButton = new javax.swing.JButton();
- stopButton = new javax.swing.JButton();
+ java.awt.GridBagConstraints gridBagConstraints;
+
+ fullScreenButton = new javax.swing.JButton();
+ jTextField1 = new javax.swing.JTextField();
+ setButton = new javax.swing.JButton();
+ pauseButton = new javax.swing.JButton();
+ stopButton = new javax.swing.JButton();
- jvcc = new JVLCCanvas();
- jvcc.setSize( 100, 100 );
- jvlc = jvcc.getJVLCObject();
+ jvcc = new JVLCPanel();
+ jvlc = jvcc.getJVLCObject();
- // FIXME: Does not work with GridBagLayout
- setLayout(new java.awt.GridBagLayout());
+ setLayout(new java.awt.GridBagLayout());
gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+ gridBagConstraints.gridwidth = java.awt.GridBagConstraints.CENTER;
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
add( jvcc , gridBagConstraints);
-
-
+
fullScreenButton.setText("FullScreen");
fullScreenButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
add( fullScreenButton, gridBagConstraints);
- jTextField1.setText("URL");
+ jTextField1.setText("file://a.avi");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
add(stopButton, gridBagConstraints);
-
+
pack();
+
+
+
}
private void stopButtonActionPerformed(java.awt.event.ActionEvent evt) {
- jvlc.stop();
+ try {
+ //mci.stop(new Position(10000, PositionOrigin.ABSOLUTE, PositionKey.MEDIATIME));
+ jvlc.playlist.stop();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
private void pauseButtonActionPerformed(java.awt.event.ActionEvent evt) {
- jvlc.pause();
+ try {
+ //System.out.println(mci.getMediaPosition(PositionOrigin.ABSOLUTE, PositionKey.BYTECOUNT));
+ jvlc.playlist.togglePause();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
private void setButtonActionPerformed(java.awt.event.ActionEvent evt) {
- jvlc.stop();
- jvlc.playlistClear();
- jvlc.addTarget( jTextField1.getText(), null, 1, -666 );
- jvlc.play();
+ try {
+ jvlc.playlist.add("file://a.avi", "a.avi");
+ jvlc.playlist.play(-1, null);
+ } catch (VLCException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
private void fullScreenButtonActionPerformed(java.awt.event.ActionEvent evt) {
- jvlc.fullScreen();
+ //jvlc.fullScreen();
}
private javax.swing.JButton setButton;
private javax.swing.JButton stopButton;
private javax.swing.JButton fullScreenButton;
private javax.swing.JTextField jTextField1;
- private javax.swing.JPanel jPanel;
- private JVLCCanvas jvcc;
+ private JVLCPanel jvcc;
public JVLC jvlc;
+ //MediaControlInstance mci;
+
}
public class VlcClient {
public static void main(String[] args) {
- Frame f = new VLCPlayerFrame();
- f.setBounds(0, 0, 500, 500);
- f.addWindowListener( new WindowAdapter() {
- public void windowClosing(WindowEvent ev) {
- System.exit(0);
- }
- } );
- f.setVisible(true);
- }
+ Frame f = new VLCPlayerFrame();
+ f.setBounds(0, 0, 500, 500);
+ f.addWindowListener( new WindowAdapter() {
+ public void windowClosing(WindowEvent ev) {
+ System.exit(0);
+ }
+ } );
+ f.setVisible(true);
+ }
}