libvlcjni.c 1.35 KB
Newer Older
1
2
3
#include <string.h>
#include <jni.h>

4
#include <vlc/vlc.h>
5

6
#include "libvlcjni.h"
7

8
jint Java_vlc_android_libVLC_init(JNIEnv *env, jobject thiz)
9
10
{
    const char *argv[] = { "-I dummy", "-vvv", "--no-plugins-cache" };
11
    return (jint)libvlc_new_with_builtins( 3, argv, vlc_builtins_modules );
12
13
}

14
void Java_vlc_android_libVLC_destroy(JNIEnv *env, jobject thiz, jint instance)
15
16
17
18
19
{
    libvlc_instance_t *p_instance = (libvlc_instance_t*)instance;
    libvlc_release(p_instance);
}

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
void Java_vlc_android_libVLC_readMedia(JNIEnv *env, jobject thiz, jint instance)
{
    /* Create a new item */
    libvlc_media_t *m = libvlc_media_new_path((libvlc_instance_t*)instance, "/sdcard/test.mp3");

    /* Create a media player playing environement */
    libvlc_media_player_t *mp = libvlc_media_player_new_from_media(m);

    /* No need to keep the media now */
    libvlc_media_release(m);

    libvlc_media_player_play(mp);

    sleep(10000);

    libvlc_media_player_release(mp);
}

38
39
jstring Java_vlc_android_libVLC_version(JNIEnv* env, jobject thiz)
{
40
41
    return (*env)->NewStringUTF(env, libvlc_get_version());
}
42
43
44
45
46
47
48
49
50
51

jstring Java_vlc_android_libVLC_compiler(JNIEnv* env, jobject thiz)
{
    return (*env)->NewStringUTF(env, libvlc_get_compiler());
}

jstring Java_vlc_android_libVLC_changeset(JNIEnv* env, jobject thiz)
{
    return (*env)->NewStringUTF(env, libvlc_get_changeset());
}