Skip to content

Video is displayed as boxed instead of filling the whole VLCVideoLayout area

Description

Video output doesn't fill VLCVideoLayout window in a ListView Adapter.

Here is my xml layout.

            <FrameLayout
                android:layout_width="match_parent"
                android:layout_marginRight="30dp"
                android:layout_height="@dimen/y460">
                <org.videolan.libvlc.util.VLCVideoLayout
                    android:id="@+id/video_layout"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="top" />
            </FrameLayout>

Here is the code

    private LibVLC mLibVLC = null;
    private MediaPlayer mMediaPlayer = null;
    private VLCVideoLayout mVideoLayout = null;
    private static final boolean USE_TEXTURE_VIEW = false;
    private static final boolean ENABLE_SUBTITLES = false;
    mVideoLayout = convertView.findViewById(R.id.video_layout);
    final ArrayList<String> args = new ArrayList<>();
    args.add("--rtsp-tcp");
    args.add("--vout=android-display");
    args.add("-vvv");
    args.add("--no-audio");
    mLibVLC = new LibVLC(getContext(), args);
    mMediaPlayer = new MediaPlayer(mLibVLC);
    final IVLCVout vout = mMediaPlayer.getVLCVout();
    vout.setWindowSize(mVideoLayout.getWidth(), mVideoLayout.getHeight());
    mMediaPlayer.attachViews(mVideoLayout, null, ENABLE_SUBTITLES, USE_TEXTURE_VIEW);
    try {
          Uri uri = Uri.parse(Content.getPlayHost(device_sn));
          final Media media = new Media(mLibVLC, uri);
          media.setHWDecoderEnabled(true,true);
          mMediaPlayer.setMedia(media);
          media.release();
        } catch (Exception e) {
          throw new RuntimeException("Invalid URL");
        }
        mVideoLayout.setVisibility(View.VISIBLE);
        mLlLoading.setVisibility(View.INVISIBLE);
        mMediaPlayer.play();

Expected behavior

1080p Video output should fit the width of layout

Actual behavior

Video plays boxed in

Steps to reproduce

Screenshot / video

Context

App version

Android version

Device model

App mode

Smartphone

TV

AutoScreenshot_20210506-111200