Skip to content

Commit

Permalink
Add video fit mode API
Browse files Browse the repository at this point in the history
  • Loading branch information
caprica committed Apr 15, 2024
1 parent 08a9468 commit 8bb5d16
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/main/java/uk/co/caprica/vlcj/player/base/VideoApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package uk.co.caprica.vlcj.player.base;

import com.sun.jna.ptr.IntByReference;
import uk.co.caprica.vlcj.binding.internal.libvlc_video_fit_mode_t;
import uk.co.caprica.vlcj.binding.support.strings.NativeString;
import uk.co.caprica.vlcj.binding.internal.libvlc_video_adjust_option_t;
import uk.co.caprica.vlcj.binding.internal.libvlc_video_viewpoint_t;
Expand All @@ -29,6 +30,7 @@
import static uk.co.caprica.vlcj.binding.lib.LibVlc.libvlc_media_player_set_video_title_display;
import static uk.co.caprica.vlcj.binding.lib.LibVlc.libvlc_video_get_adjust_float;
import static uk.co.caprica.vlcj.binding.lib.LibVlc.libvlc_video_get_adjust_int;
import static uk.co.caprica.vlcj.binding.lib.LibVlc.libvlc_video_get_display_fit;
import static uk.co.caprica.vlcj.binding.lib.LibVlc.libvlc_video_get_scale;
import static uk.co.caprica.vlcj.binding.lib.LibVlc.libvlc_video_get_size;
import static uk.co.caprica.vlcj.binding.lib.LibVlc.libvlc_video_new_viewpoint;
Expand All @@ -39,8 +41,10 @@
import static uk.co.caprica.vlcj.binding.lib.LibVlc.libvlc_video_set_crop_ratio;
import static uk.co.caprica.vlcj.binding.lib.LibVlc.libvlc_video_set_crop_window;
import static uk.co.caprica.vlcj.binding.lib.LibVlc.libvlc_video_set_deinterlace;
import static uk.co.caprica.vlcj.binding.lib.LibVlc.libvlc_video_set_display_fit;
import static uk.co.caprica.vlcj.binding.lib.LibVlc.libvlc_video_set_scale;
import static uk.co.caprica.vlcj.binding.lib.LibVlc.libvlc_video_update_viewpoint;
import static uk.co.caprica.vlcj.player.base.VideoFitMode.videoFitMode;

/**
* Behaviour pertaining to media player video.
Expand Down Expand Up @@ -203,6 +207,24 @@ public void setAspectRatio(String aspectRatio) {
libvlc_video_set_aspect_ratio(mediaPlayerInstance, aspectRatio);
}

/**
* Get the video fit mode.
*
* @return fit mode
*/
public VideoFitMode displayFit() {
return videoFitMode(libvlc_video_get_display_fit(mediaPlayerInstance));
}

/**
* Set the video fit mode.
*
* @param fitMode fit mode
*/
public void setDisplayFit(VideoFitMode fitMode) {
libvlc_video_set_display_fit(mediaPlayerInstance, fitMode.intValue());
}

/**
* Get the current video scale (zoom).
*
Expand Down
58 changes: 58 additions & 0 deletions src/main/java/uk/co/caprica/vlcj/player/base/VideoFitMode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* This file is part of VLCJ.
*
* VLCJ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VLCJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VLCJ. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2009-2024 Caprica Software Limited.
*/

package uk.co.caprica.vlcj.player.base;

import java.util.HashMap;
import java.util.Map;

/**
* Enumeration of video fit modes.
*/
public enum VideoFitMode {

libvlc_video_fit_none(0), /**< Explicit zoom set by \ref libvlc_video_set_scale */
libvlc_video_fit_smaller(1), /**< Fit inside / to smallest display dimension */
libvlc_video_fit_larger(2), /**< Fit outside / to largest display dimension */
libvlc_video_fit_width(3), /**< Fit to display width */
libvlc_video_fit_height(4);

private static final Map<Integer, VideoFitMode> INT_MAP = new HashMap<Integer, VideoFitMode>();

static {
for (VideoFitMode value : VideoFitMode.values()) {
INT_MAP.put(value.intValue, value);
}
}

public static VideoFitMode videoFitMode(int intValue) {
return INT_MAP.get(intValue);
}

private final int intValue;

VideoFitMode(int intValue) {
this.intValue = intValue;
}

public int intValue() {
return intValue;
}

}

0 comments on commit 8bb5d16

Please sign in to comment.