Exoplayer Fullscreen - PullRequest
       61

Exoplayer Fullscreen

0 голосов
/ 07 июня 2018

Я пытаюсь сделать так, чтобы видеоплеер, то есть Exoplayer, работал в полноэкранном режиме при нажатии кнопки, но, к сожалению, я не могу этого сделать, поскольку проигрыватель покрывает только половину экрана.

Прикрепление снимков экрана, показывающих, какИгрок смотрит в ландшафтном режиме: The Player covers half the screen instead of covering full screen

Любой, кто может мне помочь.Заранее спасибо

player.xml

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
  <ScrollView
    android:layout_width="match_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="0.4"
            android:orientation="vertical"
            android:background="#FFFFFF"
            android:id="@+id/name">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:id="@+id/textholder">
              <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="12dp"
                    android:layout_marginTop="20dp"
                    android:text="This is a Dummy text to implement Scroll View in this application"
                    android:textColor="#424242"
                    android:textSize="50sp"
                    android:textStyle="bold"
                    android:id="@+id/text"
                   />
            </LinearLayout>
       </LinearLayout>
        <FrameLayout
            android:id="@+id/main_media_frame"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:background="#000000">

            <com.google.android.exoplayer2.ui.PlayerView
                android:id="@+id/player_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="fill" >
            </com.google.android.exoplayer2.ui.PlayerView>
        </FrameLayout>
        <LinearLayout
            android:id="@+id/videoDetailsLayout"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="0.52"
            android:orientation="vertical"
            android:background="#FFFFFF">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:id="@+id/vd">
                <TextView
                    android:id="@+id/VideoName"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="12dp"
                    android:layout_marginTop="20dp"
                    android:text="Big Buck Bunny"
                    android:textColor="#424242"
                    android:textSize="18sp"
                    android:textStyle="bold"
                    />
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:padding="10dp"
                android:orientation="vertical"
                android:id="@+id/videoDetailsLayoutd">
                <TextView
                    android:id="@+id/vast_tag_name"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="12dp"
                    android:layout_marginTop="20dp"
                    android:text="Vast Tags"
                    android:textColor="#424242"
                    android:textSize="18sp"
                    android:textStyle="bold"
                    />
                <TextView
                    android:id="@+id/vast_tags"
                    android:layout_width="wrap_content"
                    android:layout_height="400dp"
                    android:layout_marginLeft="12dp"
                    android:layout_marginTop="20dp"
                    android:textColor="#424242"
                    android:textSize="18sp"
                    />
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>
</ScrollView>

Код для полного экрана:

private void openFullscreenDialog() {

    videoDetailsLayout.setVisibility(LinearLayout.GONE);
    vast_tags.setVisibility(LinearLayout.GONE);
    name.setVisibility(LinearLayout.GONE);

    ((ViewGroup) playerView.getParent()).setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION //hide nav bar
            | View.SYSTEM_UI_FLAG_FULLSCREEN //hide status bar
            | View.SYSTEM_UI_FLAG_IMMERSIVE);

    mFullScreenIcon.setImageDrawable(ContextCompat.getDrawable(PlayerActivity.this, R.drawable.ic_fullscreen_shrink));
    mExoPlayerFullscreen = true;
    //For explicitly changing the Orientation to Landscape
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    try {
        vast_tags.append("Fullscreen \n");
        videoEvents.playerStateChange(PlayerState.FULLSCREEN);
    } catch (Exception e) {
        Logger.d("Error is " + e.getMessage());
    }
}

1 Ответ

0 голосов
/ 07 июня 2018

Ваш exoplayer находится внутри FrameLayout, который имеет фиксированную высоту 200dp.Когда вы помещаете match_parent в качестве атрибута высоты для exoplayer, это означает заполнение высоты его непосредственного родителя, что в данном случае составляет 200dp FrameLayout.

Один из способов решить эту проблему - изменить высоту exoplayer.родитель для match_parent.Но так как макет не структурирован оптимально, вам нужно будет многое изменить, сохраняя тот же макет.Я бы предложил вам прочитать следующую ссылку на простой линейный дизайн макета , чтобы лучше понять.

...