1 /*****************************************************************************
2 * JVLC.java: global class for vlc Java Bindings
3 *****************************************************************************
4 * Copyright (C) 1998-2004 the VideoLAN team
8 * Authors: Filippo Carone <filippo@carone.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 import java.awt.Dialog;
27 import org.eclipse.swt.graphics.Point;
28 import org.eclipse.swt.widgets.Display;
29 import org.eclipse.swt.widgets.Shell;
30 import org.eclipse.swt.widgets.Canvas;
31 import org.eclipse.swt.SWT;
32 import org.eclipse.swt.widgets.Button;
33 import org.eclipse.swt.widgets.Text;
35 import org.videolan.jvlc.*;
38 public class SWTUglyPlayer {
40 private Shell sShell = null; // @jve:decl-index=0:visual-constraint="230,12"
41 private Canvas canvas = null;
42 private SWTVideoWidget vlc = null;
43 private Button button = null;
44 private Text text = null;
45 private Button button1 = null;
46 private Button button2 = null;
47 private Display display = new Display();
49 * This method initializes sShell
51 private void createSShell() {
52 sShell = new Shell(display);
53 sShell.setText("Shell");
55 sShell.setSize(new org.eclipse.swt.graphics.Point(339,303));
56 button = new Button(sShell, SWT.NONE);
57 button.setText("Play");
58 button.setSize(new org.eclipse.swt.graphics.Point(70,30));
59 button.setLocation(new org.eclipse.swt.graphics.Point(26,185));
60 button.addMouseListener(new org.eclipse.swt.events.MouseAdapter() {
61 public void mouseDown(org.eclipse.swt.events.MouseEvent e) {
62 vlc.getJVLC().playlist.add(text.getText(), text.getText());
63 vlc.getJVLC().playlist.play(-1, null);
66 text = new Text(sShell, SWT.BORDER);
67 text.setBounds(new org.eclipse.swt.graphics.Rectangle(26,222,200,25));
68 text.setText("~/a.avi");
69 button1 = new Button(sShell, SWT.NONE);
70 button1.setLocation(new org.eclipse.swt.graphics.Point(120,186));
71 button1.setText("Pause");
72 button1.setSize(new org.eclipse.swt.graphics.Point(70,30));
73 button1.addMouseListener(new org.eclipse.swt.events.MouseAdapter() {
74 public void mouseDown(org.eclipse.swt.events.MouseEvent e) {
75 vlc.getJVLC().playlist.pause();
78 button2 = new Button(sShell, SWT.NONE);
79 button2.setText("Stop");
80 button2.setSize(new org.eclipse.swt.graphics.Point(70,30));
81 button2.setLocation(new org.eclipse.swt.graphics.Point(221,188));
82 button2.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
83 public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
84 vlc.getJVLC().playlist.stop();
90 * This method initializes canvas
93 private void createCanvas() {
94 canvas = new Canvas(sShell, SWT.EMBEDDED);
95 canvas.setBounds(new org.eclipse.swt.graphics.Rectangle(22,15,248,145));
96 vlc = new SWTVideoWidget( canvas );
99 public Canvas getCanvas() {
103 public SWTUglyPlayer( ) {
106 while( !sShell.isDisposed())
108 if(!display.readAndDispatch())
114 static public void main( String[] args ) {
115 SWTUglyPlayer swt = new SWTUglyPlayer();