PierfrancescoSoffritti / android-youtube-player

YouTube Player library for Android and Chromecast, stable and customizable.
https://pierfrancescosoffritti.github.io/android-youtube-player/
MIT License
3.44k stars 765 forks source link

Full screen has margin from the screen #1086

Closed abbasiehsan1991 closed 11 months ago

abbasiehsan1991 commented 11 months ago

Question / Problem

Summary

I try to use full-screen mode, but when I play a video there is a big space to the left and right if the video with the screen. What I did is the same as the sample project btw. I used a FrameLayout for full screen.

What I've tried

My XML:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView
        android:id="@+id/youtube_player_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone"
        app:layout_constraintStart_toStartOf="parent"
        app:enableAutomaticInitialization="false"
        app:layout_constraintTop_toTopOf="parent" />

    <FrameLayout
        android:id="@+id/full_screen_view_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

This is what I'm doing for going to full screen:

   youTubePlayerView.addFullscreenListener(object : FullscreenListener {
            override fun onEnterFullscreen(fullscreenView: View, exitFullscreen: () -> Unit) {
                requireActivity().requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
                youTubePlayerView.visibility = View.GONE
                fullscreenViewContainer.visibility = View.VISIBLE
                fullscreenViewContainer.addV

iew(fullscreenView)
            }

            override fun onExitFullscreen() {
                requireActivity().requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
                youTubePlayerView.visibility = View.VISIBLE
                fullscreenViewContainer.visibility = View.GONE
            }
        })

As you can see in the below video, when I click on the full-screen button, the video is not filling the screen size, but when the video reaches to the end it full fill the screen. I'm not this is a bug or something on purpose.

https://github.com/PierfrancescoSoffritti/android-youtube-player/assets/23223511/4a53ec74-2c89-454d-b09a-d8690bc8a36e

PierfrancescoSoffritti commented 11 months ago

The screenshot you linked is in portrait mode, but the video aspect ratio is landscape. It is expected that you see black bars on the top and bottom.

abbasiehsan1991 commented 11 months ago

Hey, Thanks for your quick response. This is for the recording screen thing. the device is in the landscape too. But anyway I was pointing to the space from the left and right sides. As you can see the video is not filling the view port completely but the share button is at the top right side. telegram-cloud-photo-size-2-5415971069430454084-y

PierfrancescoSoffritti commented 11 months ago

This is the same issue, the aspect ratio of the video causes the black bands. If you remove the toolbar at the top you'll see the black bars being smaller.