[Android] LibVLC: MediaPlayer: add Set/Get Scale methods

Thomas Guillem git at videolan.org
Mon Nov 28 16:39:10 CET 2016


vlc-android | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Nov 24 10:58:51 2016 +0100| [f8fc84e247ab827b0052eb67d62b1c48d810953f] | committer: Thomas Guillem

LibVLC: MediaPlayer: add Set/Get Scale methods

> https://code.videolan.org/videolan/vlc-android/commit/f8fc84e247ab827b0052eb67d62b1c48d810953f
---

 libvlc/jni/libvlcjni-mediaplayer.c              | 23 +++++++++++++++++++++++
 libvlc/src/org/videolan/libvlc/MediaPlayer.java | 25 +++++++++++++++++++++++++
 2 files changed, 48 insertions(+)

diff --git a/libvlc/jni/libvlcjni-mediaplayer.c b/libvlc/jni/libvlcjni-mediaplayer.c
index b24ca59..f63d242 100644
--- a/libvlc/jni/libvlcjni-mediaplayer.c
+++ b/libvlc/jni/libvlcjni-mediaplayer.c
@@ -881,6 +881,29 @@ Java_org_videolan_libvlc_MediaPlayer_nativeSetSpuDelay(JNIEnv *env,
     return libvlc_video_set_spu_delay(p_obj->u.p_mp, delay) == 0 ? true : false;
 }
 
+float
+Java_org_videolan_libvlc_MediaPlayer_nativeGetScale(JNIEnv *env, jobject thiz)
+{
+    vlcjni_object *p_obj = VLCJniObject_getInstance(env, thiz);
+
+    if (!p_obj)
+        return 0.f;
+
+    return libvlc_video_get_scale(p_obj->u.p_mp);
+}
+
+void
+Java_org_videolan_libvlc_MediaPlayer_nativeSetScale(JNIEnv *env, jobject thiz,
+                                                    jfloat factor)
+{
+    vlcjni_object *p_obj = VLCJniObject_getInstance(env, thiz);
+
+    if (!p_obj)
+        return;
+
+    libvlc_video_set_scale(p_obj->u.p_mp, factor);
+}
+
 jboolean
 Java_org_videolan_libvlc_MediaPlayer_nativeAddSlave(JNIEnv *env,
                                                     jobject thiz, jint type,
diff --git a/libvlc/src/org/videolan/libvlc/MediaPlayer.java b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
index 94cb72f..676a92e 100644
--- a/libvlc/src/org/videolan/libvlc/MediaPlayer.java
+++ b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
@@ -476,6 +476,29 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
     }
 
     /**
+     * Get the current video scaling factor
+     *
+     * @return the currently configured zoom factor, or 0. if the video is set to fit to the
+     * output window/drawable automatically.
+     */
+    public float getScale() {
+        return nativeGetScale();
+    }
+
+    /**
+     * Set the video scaling factor
+     *
+     * That is the ratio of the number of pixels on screen to the number of pixels in the original
+     * decoded video in each dimension. Zero is a special value; it will adjust the video to the
+     * output window/drawable (in windowed mode) or the entire screen.
+     *
+     * @param scale the scaling factor, or zero
+     */
+    public void setScale(float scale) {
+        nativeSetScale(scale);
+    }
+
+    /**
      * Selects an audio output module.
      * Any change will take effect only after playback is stopped and
      * restarted. Audio output cannot be changed while playing.
@@ -874,6 +897,8 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
     private native void nativePlay();
     private native void nativeStop();
     private native void nativeSetVideoTitleDisplay(int position, int timeout);
+    private native float nativeGetScale();
+    private native void nativeSetScale(float scale);
     private native boolean nativeSetAudioOutput(String aout);
     private native boolean nativeSetAudioOutputDevice(String id);
     private native Title[] nativeGetTitles();



More information about the Android mailing list