1
/*****************************************************************************
2
* playlist-jni.cc: JNI native playlist functions for VLC Java Bindings
3
*****************************************************************************
4
* Copyright (C) 1998-2006 the VideoLAN team
6
* Authors: Filippo Carone <filippo@carone.org>
11
* This program is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation; either version 2 of the License, or
14
* (at your option) any later version.
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with this program; if not, write to the Free Software
23
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24
*****************************************************************************/
28
#include <vlc/libvlc.h>
32
/* JVLC internal imports, generated by gcjh */
33
#include "../includes/Playlist.h"
38
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Playlist__1playlist_1add (JNIEnv *env, jobject _this, jstring uri, jstring name, jobjectArray options) {
44
const char** ppsz_options = NULL;
45
const char* psz_uri = env->GetStringUTFChars( uri, 0 );
46
const char* psz_name = env->GetStringUTFChars( name, 0 );
48
if ( options != NULL ) {
49
i_options = ( int ) env->GetArrayLength( ( jarray ) options ) + 1;
50
ppsz_options = ( const char ** ) malloc( i_options * sizeof( char* ) );
51
sprintf( ( char * ) ppsz_options[0], "%s", "jvlc" );
53
for (int i = 0; i < i_options - 1; i++) {
55
env->GetStringUTFChars( ( jstring ) env->GetObjectArrayElement( options, i ), 0 );
57
res = libvlc_playlist_add_extended( ( libvlc_instance_t * ) instance, psz_uri, psz_name, i_options, ppsz_options, exception );
62
res = libvlc_playlist_add( ( libvlc_instance_t * ) instance, psz_uri, psz_name, exception );
67
if (psz_uri != NULL) {
68
env->ReleaseStringUTFChars( uri, psz_uri );
71
if (psz_name != NULL) {
72
env->ReleaseStringUTFChars( name, psz_name );
79
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1play (JNIEnv *env, jobject _this, jint id, jobjectArray options)
85
const char** ppsz_options = NULL;
87
if ( options != NULL ) {
88
i_options = ( int ) env->GetArrayLength( ( jarray ) options );
89
ppsz_options = ( const char ** ) malloc( i_options * sizeof( char* ) );
90
for ( int i = 0; i < i_options - 1; i++ ) {
92
env->GetStringUTFChars( ( jstring ) env->GetObjectArrayElement( options, i ), 0 );
96
libvlc_playlist_play( ( libvlc_instance_t * ) instance, id, i_options, ( char ** ) ppsz_options, exception );
102
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1pause (JNIEnv *env, jobject _this)
106
libvlc_playlist_pause( ( libvlc_instance_t* ) instance, exception );
108
CHECK_EXCEPTION_FREE ;
111
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1stop (JNIEnv *env, jobject _this)
115
libvlc_playlist_stop( ( libvlc_instance_t* ) instance, exception );
117
while ( libvlc_playlist_isplaying( (libvlc_instance_t*) instance, exception ) )
123
CHECK_EXCEPTION_FREE ;
126
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1next (JNIEnv *env, jobject _this)
130
libvlc_playlist_next( ( libvlc_instance_t* ) instance, exception );
132
CHECK_EXCEPTION_FREE ;
135
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1prev (JNIEnv *env, jobject _this)
139
libvlc_playlist_prev( (libvlc_instance_t*) instance, exception );
141
CHECK_EXCEPTION_FREE ;
144
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1clear (JNIEnv *env, jobject _this)
148
libvlc_playlist_clear( (libvlc_instance_t*) instance, exception );
150
CHECK_EXCEPTION_FREE ;
153
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1deleteItem (JNIEnv *env, jobject _this, jint itemID)
157
libvlc_playlist_delete_item( ( libvlc_instance_t * ) instance, itemID, exception );
159
CHECK_EXCEPTION_FREE ;
163
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Playlist__1itemsCount (JNIEnv *env, jobject _this)
168
res = libvlc_playlist_items_count( (libvlc_instance_t*) instance, exception );
170
CHECK_EXCEPTION_FREE ;
176
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Playlist__1isRunning (JNIEnv *env, jobject _this)
181
res = libvlc_playlist_isplaying( (libvlc_instance_t*) instance, exception );
183
CHECK_EXCEPTION_FREE ;