Commit 6f926ff4 authored by Rafaël Carré's avatar Rafaël Carré

GetMediaPlayer: simplify, return correct type

parent 39c6c813
......@@ -23,14 +23,12 @@
#define NAME(FUN) NAME2(CLASS, FUN)
jint getMediaPlayer(JNIEnv *env, jobject thiz)
libvlc_media_player_t *getMediaPlayer(JNIEnv *env, jobject thiz)
{
jclass clazz = (*env)->GetObjectClass(env, thiz);
jfieldID fieldMP = (*env)->GetFieldID(env, clazz,
"mMediaPlayerInstance", "I");
return (*env)->GetIntField(env, thiz, fieldMP);
return (libvlc_media_player_t*)(*env)->GetIntField(env, thiz, fieldMP);
}
jboolean releaseMediaPlayer(JNIEnv *env, jobject thiz)
......@@ -470,137 +468,98 @@ jlong Java_org_videolan_vlc_android_LibVLC_getLengthFromFile(JNIEnv *env, jobjec
jboolean Java_org_videolan_vlc_android_LibVLC_hasMediaPlayer(JNIEnv *env, jobject thiz)
{
jint mediaPlayer = getMediaPlayer(env, thiz);
if (mediaPlayer != 0)
return 1;
return 0;
return !!getMediaPlayer(env, thiz);
}
jboolean Java_org_videolan_vlc_android_LibVLC_isPlaying(JNIEnv *env, jobject thiz)
{
jint mediaPlayer = getMediaPlayer(env, thiz);
if (mediaPlayer != 0)
{
libvlc_media_player_t *mp = (libvlc_media_player_t*) mediaPlayer;
return ( libvlc_media_player_is_playing( mp ) == 1 );
}
libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
if (mp)
return !!libvlc_media_player_is_playing(mp);
return 0;
}
jboolean Java_org_videolan_vlc_android_LibVLC_isSeekable(JNIEnv *env, jobject thiz)
{
jint mediaPlayer = getMediaPlayer(env, thiz);
if (mediaPlayer != 0)
{
libvlc_media_player_t *mp = (libvlc_media_player_t*) mediaPlayer;
return ( libvlc_media_player_is_seekable( mp ) == 1 );
}
libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
if (mp)
return !!libvlc_media_player_is_seekable(mp);
return 0;
}
void Java_org_videolan_vlc_android_LibVLC_play(JNIEnv *env, jobject thiz)
{
jint mediaPlayer = getMediaPlayer(env, thiz);
if (mediaPlayer != 0)
{
libvlc_media_player_t *mp = (libvlc_media_player_t*) mediaPlayer;
libvlc_media_player_play( mp );
}
libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
if (mp)
libvlc_media_player_play(mp);
}
void Java_org_videolan_vlc_android_LibVLC_pause(JNIEnv *env, jobject thiz)
{
jint mediaPlayer = getMediaPlayer(env, thiz);
if (mediaPlayer != 0)
{
libvlc_media_player_t *mp = (libvlc_media_player_t*) mediaPlayer;
libvlc_media_player_pause( mp );
}
libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
if (mp)
libvlc_media_player_pause(mp);
}
void Java_org_videolan_vlc_android_LibVLC_stop(JNIEnv *env, jobject thiz)
{
jint mediaPlayer = getMediaPlayer(env, thiz);
if (mediaPlayer != 0)
{
libvlc_media_player_t *mp = (libvlc_media_player_t*) mediaPlayer;
libvlc_media_player_stop( mp );
}
libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
if (mp)
libvlc_media_player_stop(mp);
}
jint Java_org_videolan_vlc_android_LibVLC_getVolume(JNIEnv *env, jobject thiz)
{
jint mediaPlayer = getMediaPlayer(env, thiz);
if (mediaPlayer != 0)
{
libvlc_media_player_t *mp = (libvlc_media_player_t*) mediaPlayer;
return (jint) libvlc_audio_get_volume( mp );
}
libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
if (mp)
return (jint) libvlc_audio_get_volume(mp);
return -1;
}
jint Java_org_videolan_vlc_android_LibVLC_setVolume(JNIEnv *env, jobject thiz, jint volume)
{
jint mediaPlayer = getMediaPlayer(env, thiz);
if (mediaPlayer != 0)
{
libvlc_media_player_t *mp = (libvlc_media_player_t*) mediaPlayer;
libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
if (mp)
//Returns 0 if the volume was set, -1 if it was out of range or error
return (jint) libvlc_audio_set_volume( mp, (int) volume );
}
return (jint) libvlc_audio_set_volume(mp, (int) volume);
return -1;
}
jlong Java_org_videolan_vlc_android_LibVLC_getTime(JNIEnv *env, jobject thiz)
{
jint mediaPlayer = getMediaPlayer(env, thiz);
if (mediaPlayer != 0)
{
libvlc_media_player_t *mp = (libvlc_media_player_t*) mediaPlayer;
return libvlc_media_player_get_time( mp );
}
libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
if (mp)
return libvlc_media_player_get_time(mp);
return -1;
}
void Java_org_videolan_vlc_android_LibVLC_setTime(JNIEnv *env, jobject thiz, jlong time)
{
jint mediaPlayer = getMediaPlayer(env, thiz);
if (mediaPlayer != 0)
{
libvlc_media_player_t *mp = (libvlc_media_player_t*) mediaPlayer;
libvlc_media_player_set_time( mp, time );
}
libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
if (mp)
libvlc_media_player_set_time(mp, time);
}
jfloat Java_org_videolan_vlc_android_LibVLC_getPosition(JNIEnv *env, jobject thiz)
{
jint mediaPlayer = getMediaPlayer(env, thiz);
if (mediaPlayer != 0)
{
libvlc_media_player_t *mp = (libvlc_media_player_t*) mediaPlayer;
return (jfloat) libvlc_media_player_get_position( mp );
}
libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
if (mp)
return (jfloat) libvlc_media_player_get_position(mp);
return -1;
}
void Java_org_videolan_vlc_android_LibVLC_setPosition(JNIEnv *env, jobject thiz, jfloat pos)
{
jint mediaPlayer = getMediaPlayer(env, thiz);
if (mediaPlayer != 0)
{
libvlc_media_player_t *mp = (libvlc_media_player_t*) mediaPlayer;
libvlc_media_player_set_position( mp, pos );
}
libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
if (mp)
libvlc_media_player_set_position(mp, pos);
}
jlong Java_org_videolan_vlc_android_LibVLC_getLength(JNIEnv *env, jobject thiz)
{
jint mediaPlayer = getMediaPlayer(env, thiz);
if (mediaPlayer != 0)
{
libvlc_media_player_t *mp = (libvlc_media_player_t*) mediaPlayer;
return (jlong) libvlc_media_player_get_length( mp );
}
libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
if (mp)
return (jlong) libvlc_media_player_get_length(mp);
return -1;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment