JAVALDFLAGS = -L../../src -lvlc `top_builddir=../.. ../../vlc-config --libs builtin vlc pic`
# Build targets
-all: libjvlc.so VlcClient
+all: libjvlc.so VlcClient VLCExample
libjvlc.so: vlc-libvlc-jni.o vlc-graphics-jni.o
$(CXX) -shared vlc-libvlc-jni.o vlc-graphics-jni.o $(LIBJINCLUDES) $(LDFLAGS) $(JAVALDFLAGS) -o libjvlc.so
VlcClient: $(OBJECTS)
$(JCC) -C VlcClient.java
+VLCExample: $(OBJECTS)
+ $(JCC) -C VLCExample.java
+
%.class: %.java
$(JCC) -C $?
$(JCH) org/videolan/jvlc/$(*F)
--- /dev/null
+import org.videolan.jvlc.JVLC;
+
+
+public class VLCExample
+{
+
+ public static void main( String[] args )
+ {
+ boolean videoInput = false;
+ JVLC jvlc = new JVLC();
+
+ jvlc.playlist.add("file://" + System.getProperty( "user.dir" ) + "/a.avi", "a.avi");
+ jvlc.playlist.add("file://" + System.getProperty( "user.dir" ) + "/a.mp3", "a.mp3");
+ jvlc.playlist.play( -1 , null );
+
+ while (! jvlc.isInputPlaying()) ;
+
+ // testing vout functionalities
+
+ try {
+ Thread.sleep(500);
+ if (jvlc.hasVout()) videoInput = true;
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ if (videoInput) {
+ System.out.print(jvlc.getVideoWidth());
+ System.out.print("x");
+ System.out.println(jvlc.getVideoHeight());
+ }
+ try
+ {
+ if (videoInput) {
+ System.out.print("Fullscreen... ");
+ jvlc.setFullscreen(true);
+ Thread.sleep(3000);
+ System.out.println("real size.");
+ jvlc.setFullscreen(false);
+ System.out.print("Taking snapshot... ");
+ jvlc.getSnapshot( System.getProperty( "user.dir" ) + "/snap.png");
+ System.out.println("taken. (see " + System.getProperty( "user.dir" ) + "/snap.png )");
+ }
+ System.out.print("Muting...");
+ jvlc.setMute(true);
+ Thread.sleep(3000);
+ System.out.println("unmuting.");
+ jvlc.setMute(false);
+ Thread.sleep(3000);
+ System.out.println("Volume is: " + jvlc.getVolume());
+ System.out.print("Setting volume to 150... ");
+ jvlc.setVolume(150);
+ System.out.println("done");
+ Thread.sleep(3000);
+ System.out.println("INPUT INFORMATION");
+ System.out.println("-----------------");
+ System.out.println("Total length (ms) :\t" + jvlc.getInputLength());
+ System.out.println("Input time (ms) :\t" + jvlc.getInputTime());
+ System.out.println("Input position [0-1]:\t" + jvlc.getInputPosition());
+ if (videoInput)
+ System.out.println("Input FPS :\t" + jvlc.getInputFPS());
+
+
+ }
+
+ catch (Exception e)
+ {
+ System.out.println("Something was wrong. I die :(.");
+ jvlc.destroy();
+ }
+
+ System.out.println("Everything fine ;)");
+ System.out.println("Playing next item");
+ jvlc.playlist.next();
+
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ jvlc.destroy();
+ return;
+ }
+}
+
* currently playing playlist item.
*/
long getInputTime();
- long getInputPosition();
+ float getInputPosition();
void setInputTime();
double getInputFPS();
* Input native methods
*/
private native long _getInputLength();
- private native long _getInputPosition();
+ private native float _getInputPosition();
private native long _getInputTime();
+ private native float _getInputFPS();
/*
private native boolean _getFullscreen();
private native int _getVideoHeight();
private native int _getVideoWidth();
- private native void _getSnapshot(String filename);
+ private native void _getSnapshot(String filename);
public boolean getMute() {
return _getInputTime();
}
- public long getInputPosition() {
+ public float getInputPosition() {
return _getInputPosition();
}
}
public double getInputFPS() {
- // TODO Auto-generated method stub
- return 0;
+ return _getInputFPS();
}
public long getInstance() {
public synchronized void play(int id, String[] options) {
_play(id, options);
- while (! _inputIsPlaying()) ;
}
public synchronized void play() {
/**
* Saves a snapshot of the current video window.
- * @param filepath The full path (including filename) were to save the snapshot to.
+ * @param filepath The full path (including filename) were to save the snapshot to.
+ * If you only give a path, not including the filename, the snapshot will be saved in
+ * the specified path using vlc naming conventions.
*/
void getSnapshot(String filepath);
/*****************************************************************************
- * JVLC.java: JNI interface for vlc Java Bindings
+ * vlc-libvlc-jni.cc: JNI interface for vlc Java Bindings
*****************************************************************************
* Copyright (C) 1998-2006 the VideoLAN team
*
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC__1getVolume (JNIEnv *env, jobject _this)
-{
-
- // res is the final result
- jboolean res;
- long instance = 0;
-
- libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ));
-
- libvlc_exception_init( exception );
-
- instance = getPlaylistInstance( env, _this );
-
-
- res = (jboolean) libvlc_audio_get_mute( ( libvlc_instance_t * ) instance, exception );
-
- if ( libvlc_exception_raised( exception ))
- {
- ///\TODO: raise java exception
- printf("%s\n", libvlc_exception_get_message( exception ));
- }
-
- free( exception );
- return res;
-}
-
-JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC__1getVolume (JNIEnv *env, jobject _this, jboolean value)
{
jint res = 0;
long instance = 0;
return res;
}
+JNIEXPORT jint JNICALL Java_org_videolan_jvlc_JVLC__1getVolume (JNIEnv *env, jobject);
+
JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLC__1setVolume (JNIEnv *env, jobject _this, jint volume)
{
long instance = 0;
return res;
}
+JNIEXPORT jfloat JNICALL Java_org_videolan_jvlc_JVLC__1getInputPosition (JNIEnv *env, jobject _this)
+{
+ float res;
+ long instance = 0;
+ libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ) );
+ libvlc_input_t *input;
+
+ libvlc_exception_init( exception );
+
+ instance = getPlaylistInstance( env, _this );
+
+ input = libvlc_playlist_get_input( ( libvlc_instance_t* ) instance, exception );
+
+ res = libvlc_input_get_position( input, exception );
+ /// \todo handle exceptions
+ free( exception );
+
+ return res;
+
+}
+
+JNIEXPORT jfloat JNICALL Java_org_videolan_jvlc_JVLC__1getInputFPS (JNIEnv *env, jobject _this)
+{
+ float res;
+ long instance = 0;
+ libvlc_exception_t *exception = ( libvlc_exception_t * ) malloc( sizeof( libvlc_exception_t ) );
+ libvlc_input_t *input;
+
+ libvlc_exception_init( exception );
+
+ instance = getPlaylistInstance( env, _this );
+
+ input = libvlc_playlist_get_input( ( libvlc_instance_t* ) instance, exception );
+
+ res = libvlc_input_get_fps( input, exception );
+ /// \todo handle exceptions
+ free( exception );
+
+ return res;
+}
+
/*