[Android] [PATCH 4/4] jni: add jni_GetWindowSize
Thomas Guillem
thomas at gllm.fr
Tue Nov 25 16:20:27 CET 2014
return the up to date window width and height.
---
libvlc/jni/libvlcjni.c | 20 ++++++++++++++++++++
libvlc/src/org/videolan/libvlc/LibVLC.java | 1 +
.../videolan/vlc/gui/video/VideoPlayerActivity.java | 2 ++
3 files changed, 23 insertions(+)
diff --git a/libvlc/jni/libvlcjni.c b/libvlc/jni/libvlcjni.c
index 6b28667..c4e37d1 100644
--- a/libvlc/jni/libvlcjni.c
+++ b/libvlc/jni/libvlcjni.c
@@ -632,3 +632,23 @@ void Java_org_videolan_libvlc_LibVLC_playerNavigate(JNIEnv *env, jobject thiz, j
libvlc_media_player_navigate(mp, (unsigned) nav);
}
+// TODO: remove static variables
+static int i_window_width = 0;
+static int i_window_height = 0;
+
+void Java_org_videolan_libvlc_LibVLC_setWindowSize(JNIEnv *env, jobject thiz, jint width, jint height)
+{
+ pthread_mutex_lock(&vout_android_lock);
+ i_window_width = width;
+ i_window_height = height;
+ pthread_mutex_unlock(&vout_android_lock);
+}
+
+int jni_GetWindowSize(int *width, int *height)
+{
+ pthread_mutex_lock(&vout_android_lock);
+ *width = i_window_width;
+ *height = i_window_height;
+ pthread_mutex_unlock(&vout_android_lock);
+ return 0;
+}
diff --git a/libvlc/src/org/videolan/libvlc/LibVLC.java b/libvlc/src/org/videolan/libvlc/LibVLC.java
index 5dffb47..d8f3256 100644
--- a/libvlc/src/org/videolan/libvlc/LibVLC.java
+++ b/libvlc/src/org/videolan/libvlc/LibVLC.java
@@ -881,4 +881,5 @@ public class LibVLC {
public native int getTitleCount();
public native void playerNavigate(int navigate);
+ public native int setWindowSize(int width, int height);
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index cf11ef6..4cf4793 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -1301,6 +1301,8 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
sw = mPresentation.getWindow().getDecorView().getWidth();
sh = mPresentation.getWindow().getDecorView().getHeight();
}
+ if (mLibVLC != null)
+ mLibVLC.setWindowSize(sw, sh);
double dw = sw, dh = sh;
boolean isPortrait;
--
2.1.1
More information about the Android
mailing list