Commit 92fcb9b5 authored by Filippo Carone's avatar Filippo Carone

Java bindings update to latest JVLC (step 1/2)

JNI: unused files removed
JNI: libvlc.h dependent file added 
A sample SWT (ugly) player added
Old java bindings files removed
parent 77fa066c
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 the VideoLAN team
*
* $Id$
*
* Authors: Filippo Carone <filippo@carone.org>
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
import java.awt.Dialog;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Text;
import org.videolan.jvlc.*;
public class SWTUglyPlayer {
private Shell sShell = null; // @jve:decl-index=0:visual-constraint="230,12"
private Canvas canvas = null;
private SWTVideoWidget vlc = null;
private Button button = null;
private Text text = null;
private Button button1 = null;
private Button button2 = null;
private Display display = new Display();
/**
* This method initializes sShell
*/
private void createSShell() {
sShell = new Shell(display);
sShell.setText("Shell");
createCanvas();
sShell.setSize(new org.eclipse.swt.graphics.Point(339,303));
button = new Button(sShell, SWT.NONE);
button.setText("Play");
button.setSize(new org.eclipse.swt.graphics.Point(70,30));
button.setLocation(new org.eclipse.swt.graphics.Point(26,185));
button.addMouseListener(new org.eclipse.swt.events.MouseAdapter() {
public void mouseDown(org.eclipse.swt.events.MouseEvent e) {
vlc.getJVLC().playlist.add(text.getText(), text.getText());
vlc.getJVLC().playlist.play(-1, null);
}
});
text = new Text(sShell, SWT.BORDER);
text.setBounds(new org.eclipse.swt.graphics.Rectangle(26,222,200,25));
text.setText("~/a.avi");
button1 = new Button(sShell, SWT.NONE);
button1.setLocation(new org.eclipse.swt.graphics.Point(120,186));
button1.setText("Pause");
button1.setSize(new org.eclipse.swt.graphics.Point(70,30));
button1.addMouseListener(new org.eclipse.swt.events.MouseAdapter() {
public void mouseDown(org.eclipse.swt.events.MouseEvent e) {
vlc.getJVLC().playlist.pause();
}
});
button2 = new Button(sShell, SWT.NONE);
button2.setText("Stop");
button2.setSize(new org.eclipse.swt.graphics.Point(70,30));
button2.setLocation(new org.eclipse.swt.graphics.Point(221,188));
button2.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
vlc.getJVLC().playlist.stop();
}
});
}
/**
* This method initializes canvas
*
*/
private void createCanvas() {
canvas = new Canvas(sShell, SWT.EMBEDDED);
canvas.setBounds(new org.eclipse.swt.graphics.Rectangle(22,15,248,145));
vlc = new SWTVideoWidget( canvas );
}
public Canvas getCanvas() {
return canvas;
}
public SWTUglyPlayer( ) {
createSShell();
sShell.open();
while( !sShell.isDisposed())
{
if(!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
static public void main( String[] args ) {
SWTUglyPlayer swt = new SWTUglyPlayer();
}
}
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 the VideoLAN team
*
* $Id$
*
* Authors: Filippo Carone <filippo@carone.org>
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
import org.videolan.jvlc.*;
import java.awt.*;
......
package org.videolan.jvlc;
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/**
* This is the main Java VLC class which represents a vlc_object_t. Through this
* class it's possible to control media loading/playing. It's possible to have
* more than one JVLC object in the same program.
*/
public class JVLC {
static {
System.loadLibrary("jvlc");
}
private int id;
/**
* @param args Arguments for the vlc object. These are the same as the
* original C version of VLC.
*/
public JVLC(String[] args) {
String[] properArgs = new String[args.length + 1];
properArgs[0] = "jvlc";
for (int i = 0; i < args.length; i++)
properArgs[i+1] = args[i];
this.id = create();
init(properArgs);
}
public JVLC() {
new JVLC(new String[]{""});
}
/**
* @return Returns the ID of the VLC Object
*/
public int getID() {
return this.id;
}
/**
* Cleanup the VLC Object. It's the equivalent of
* calling VLC_Die() and VLC_CleanUp()
*/
public void quit() {
this.die();
this.cleanUp();
}
private native int create();
private native int init(String[] args);
/**
*
* Creates the interface of the videolan player
*
* @param moduleName The interface module to display
* @param blocking True if the interface is blocking, otherwise it runs on its own thread
* @param startPlay True if the player starts to play as soon as the interface is displayed
* @return An int which is &lt; 0 on error
*/
public native int addInterface(String moduleName, boolean blocking, boolean startPlay);
/**
*
* Creates the interface of the videolan player with the default interface
* or the interface set by -I
*
* @param blocking True if the interface is blocking, otherwise it runs on its own thread
* @param startPlay True if the player starts to play as soon as the interface is displayed
* @return An int which is &lt; 0 on error
*/
public int addInterface(boolean blocking, boolean startPlay) {
return addInterface(null, blocking, startPlay);
}
/**
* @return The version of the VideoLan object
*/
public native String getVersion();
public native String getError(int errorCode);
private native int die();
private native int cleanUp();
public native int setVariable(JVLCVariable jvlcVariable);
public native JVLCVariable getVariable(String varName); // XXX in progress
public native int addTarget(String URI, String[] options, int insertMode, int position);
/**
* Plays the media
*
* @return An int which is &lt; 0 on error
*/
public native int play();
/**
*
* Pauses the media. If the media is already paused, pause() restarts it.
*
* @return
*/
public native int pause();
/**
*
* Stops the media
*
* @return
*/
public native int stop();
/**
* @return True if the player is actually playing something
*/
public native boolean isPlaying();
/**
* @return The absolute position within the media
*/
public native float getPosition();
public native float setPosition(float position);
public native int getTime();
public native int setTime(int seconds, boolean relative);
public native int getLength();
public native float speedFaster();
public native float speedSlower();
public native int getPlaylistIndex();
public native int getPlaylistItems();
public native int playlistNext();
public native int playlistPrev();
public native int playlistClear();
public native int getVolume();
public native int setVolume(int volume);
public native int muteVolume();
public native int fullScreen();
}
package org.videolan.jvlc;
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/**
* This class is part of JVLC<Type>Variable pool.
*/
public class JVLCBoolVariable extends JVLCVariable {
public JVLCBoolVariable(String name, int value) throws JVLCNoSuchVariableNameException {
super(name);
this.value = (value != 0)? new Integer(1) : new Integer(0);
}
public int getBoolValue() {
return ((Integer)value).intValue();
}
}
/*
* Created on 25-nov-2005
*
* 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.
*
*/
/**
* @author Filippo Carone <filippo@carone.org>
*/
package org.videolan.jvlc;
import java.awt.Canvas;
import java.awt.Graphics;
public class JVLCCanvas extends Canvas {
public native void paint(Graphics g);
private final JVLC jvlcObject = new JVLC();
public JVLCCanvas() {
jvlcObject.addInterface("dummy", false, false);
}
public JVLC getJVLCObject() {
return jvlcObject;
}
}
package org.videolan.jvlc;
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/**
* This class is part of JVLC<Type>Variable pool.
*/
public class JVLCFloatVariable extends JVLCVariable {
public JVLCFloatVariable(String name, float value) throws JVLCNoSuchVariableNameException {
super(name);
this.value = new Float(value);
}
public float getFloatValue() {
return ((Float)value).floatValue();
}
}
package org.videolan.jvlc;
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/**
* This class is part of JVLC<Type>Variable pool.
*/
public class JVLCIntVariable extends JVLCVariable {
public JVLCIntVariable(String name, int value) throws JVLCNoSuchVariableNameException {
super(name);
this.value = new Integer(value);
}
public int getIntValue() {
return ((Integer)value).intValue();
}
}
/*
* Created on 22-nov-2005
*
* 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.
*
*/
/**
* @author Filippo Carone <filippo@carone.org>
*/
package org.videolan.jvlc;
public class JVLCNoSuchVariableNameException extends Exception {
public JVLCNoSuchVariableNameException() {
super();
// TODO Auto-generated constructor stub
}
public JVLCNoSuchVariableNameException(String message) {
super(message);
// TODO Auto-generated constructor stub
}
public JVLCNoSuchVariableNameException(String message, Throwable cause) {
super(message, cause);
// TODO Auto-generated constructor stub
}
public JVLCNoSuchVariableNameException(Throwable cause) {
super(cause);
// TODO Auto-generated constructor stub
}
}
package org.videolan.jvlc;
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/**
* This class is part of JVLC<Type>Variable pool.
*/
public class JVLCStringVariable extends JVLCVariable {
public JVLCStringVariable(String name, String value) throws JVLCNoSuchVariableNameException {
super(name);
this.value = value;
}
public String getStringValue() {
return (String)value;
}
}
package org.videolan.jvlc;
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/**
* This class is part of JVLC<Type>Variable pool.
*/
public class JVLCTimeVariable extends JVLCVariable {
public JVLCTimeVariable(String name, long value) throws JVLCNoSuchVariableNameException {
super(name);
this.value = new Long(value);
}
public long getTimeValue() {
return ((Long)value).longValue();
}
}
package org.videolan.jvlc;
/*****************************************************************************
* JVLC.java: global class for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2004 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
*
* This program is free software; you can redistribute it and/or modify