1 /*****************************************************************************
\r
2 * playlist-jni.cc: JNI native playlist functions for VLC Java Bindings
\r
3 *****************************************************************************
\r
4 * Copyright (C) 1998-2006 the VideoLAN team
\r
6 * Authors: Filippo Carone <filippo@carone.org>
\r
11 * This program is free software; you can redistribute it and/or modify
\r
12 * it under the terms of the GNU General Public License as published by
\r
13 * the Free Software Foundation; either version 2 of the License, or
\r
14 * (at your option) any later version.
\r
16 * This program is distributed in the hope that it will be useful,
\r
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
19 * GNU General Public License for more details.
\r
21 * You should have received a copy of the GNU General Public License
\r
22 * along with this program; if not, write to the Free Software
\r
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
\r
24 *****************************************************************************/
\r
26 /* These are a must*/
\r
28 #include <vlc/libvlc.h>
\r
30 #include <windows.h>
\r
32 #define usleep(var) Sleep(var/1000)
\r
38 /* JVLC internal imports, generated by gcjh */
\r
39 #include "../includes/Playlist.h"
\r
44 JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Playlist__1playlist_1add (JNIEnv *env, jobject _this, jstring uri, jstring name, jobjectArray options) {
\r
50 const char** ppsz_options = NULL;
\r
51 const char* psz_uri = env->GetStringUTFChars( uri, 0 );
\r
52 const char* psz_name = env->GetStringUTFChars( name, 0 );
\r
54 if ( options != NULL ) {
\r
55 i_options = ( int ) env->GetArrayLength( ( jarray ) options ) + 1;
\r
56 ppsz_options = ( const char ** ) malloc( i_options * sizeof( char* ) );
\r
57 sprintf( ( char * ) ppsz_options[0], "%s", "jvlc" );
\r
59 for (int i = 0; i < i_options - 1; i++) {
\r
60 ppsz_options[ i+1 ] =
\r
61 env->GetStringUTFChars( ( jstring ) env->GetObjectArrayElement( options, i ), 0 );
\r
63 res = libvlc_playlist_add_extended( ( libvlc_instance_t * ) instance, psz_uri, psz_name, i_options, ppsz_options, &exception );
\r
68 res = libvlc_playlist_add( ( libvlc_instance_t * ) instance, psz_uri, psz_name, &exception );
\r
73 if (psz_uri != NULL) {
\r
74 env->ReleaseStringUTFChars( uri, psz_uri );
\r
77 if (psz_name != NULL) {
\r
78 env->ReleaseStringUTFChars( name, psz_name );
\r
85 JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1play (JNIEnv *env, jobject _this, jint id, jobjectArray options)
\r
91 const char** ppsz_options = NULL;
\r
93 if ( options != NULL ) {
\r
94 i_options = ( int ) env->GetArrayLength( ( jarray ) options );
\r
95 ppsz_options = ( const char ** ) malloc( i_options * sizeof( char* ) );
\r
96 for ( int i = 0; i < i_options - 1; i++ ) {
\r
97 ppsz_options[ i ] =
\r
98 env->GetStringUTFChars( ( jstring ) env->GetObjectArrayElement( options, i ), 0 );
\r
102 libvlc_playlist_play( ( libvlc_instance_t * ) instance, id, i_options, ( char ** ) ppsz_options, &exception );
\r
106 while (! libvlc_playlist_isplaying( (libvlc_instance_t*) instance, &exception ) )
\r
115 JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1pause (JNIEnv *env, jobject _this)
\r
119 libvlc_playlist_pause( ( libvlc_instance_t* ) instance, &exception );
\r
124 JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1stop (JNIEnv *env, jobject _this)
\r
128 libvlc_playlist_stop( ( libvlc_instance_t* ) instance, &exception );
\r
130 while ( libvlc_playlist_isplaying( (libvlc_instance_t*) instance, &exception ) )
\r
139 JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1next (JNIEnv *env, jobject _this)
\r
143 libvlc_playlist_next( ( libvlc_instance_t* ) instance, &exception );
\r
148 JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1prev (JNIEnv *env, jobject _this)
\r
152 libvlc_playlist_prev( (libvlc_instance_t*) instance, &exception );
\r
157 JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1clear (JNIEnv *env, jobject _this)
\r
161 libvlc_playlist_clear( (libvlc_instance_t*) instance, &exception );
\r
166 JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1deleteItem (JNIEnv *env, jobject _this, jint itemID)
\r
170 libvlc_playlist_delete_item( ( libvlc_instance_t * ) instance, itemID, &exception );
\r
176 JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Playlist__1itemsCount (JNIEnv *env, jobject _this)
\r
181 res = libvlc_playlist_items_count( (libvlc_instance_t*) instance, &exception );
\r
189 JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Playlist__1isRunning (JNIEnv *env, jobject _this)
\r
194 res = libvlc_playlist_isplaying( (libvlc_instance_t*) instance, &exception );
\r
201 JNIEXPORT void JNICALL Java_org_videolan_jvlc_Playlist__1setLoop
\r
202 (JNIEnv *env, jobject _this, jboolean loop)
\r
206 libvlc_playlist_loop( (libvlc_instance_t*) instance, loop, &exception );
\r