google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.71k stars 6.02k forks source link

can't set elevation when use two StyledPlayerView in android 7 #10424

Open sajjadshahbazi opened 2 years ago

sajjadshahbazi commented 2 years ago

ExoPlayer Version

2.17.1

Devices that reproduce the issue

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Yes

Reproduction steps

I have two StyledPlayerView, which one of them for the main video and another for the playback advertisement. while playing the main movie we want to play an advertisement over the main film(when playing the advertisement we paused the main video), but the StyledPlayerView of the advertisement playing behind the StyledPlayerView of the main video in the android 7 version, while on another android device is correct. To solve this problem I became changed the visibility of StyledPlayerViews, which came a new problem on all android versions. the new problem is: change the bottom margin after any time gone and visible StyledPlayerView of the main video, while I don't have logic for change margins.

please guide me

Expected result

I expect to StyledPlayerView of advertisement over StyledPlayerView of the mani video in all android versions.

Actual result

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/motionLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:keepScreenOn="true"
    android:layoutDirection="rtl"
    app:layoutDescription="@xml/activity_tv_media_player_scene"
    tools:context=".mediaPlayer.player.TvVideoPlayerActivity">

    <com.google.android.exoplayer2.ui.StyledPlayerView
        android:id="@+id/playerView"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="@color/black"
        app:animation_enabled="false"
        app:controller_layout_id="@layout/exo_playback_control_view"
        app:hide_during_ads="true"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:resize_mode="fit"
        app:show_buffering="never" />

    ...

        <com.google.android.exoplayer2.ui.StyledPlayerView
        android:id="@+id/playerAdView"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="@color/black"
        android:focusable="true"
        app:animation_enabled="false"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:resize_mode="fit"
        app:show_buffering="never"
        app:use_controller="false"
        />

</androidx.constraintlayout.motion.widget.MotionLayout>

exo_playback_control_view :

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layoutDirection="rtl"
    android:elevation="10dp"
    >

   ... 

    <com.google.android.exoplayer2.ui.DefaultTimeBar
        android:id="@id/exo_progress"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/playerSpaceHorizontalTimeBarOfController"
        android:layout_marginEnd="@dimen/playerSpaceHorizontalTimeBarOfController"
        android:layout_marginBottom="@dimen/playerSpaceBottomTimeBarOfController"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:played_color="@color/white"
        app:scrubber_color="@color/blue"
        app:scrubber_drawable="@drawable/seekerbar_thumb"
        android:nextFocusDown="@id/exo_pause"
        app:scrubber_dragged_size="2dp"
        app:scrubber_enabled_size="1dp"
        app:animation_enabled="false"
        />

</androidx.constraintlayout.widget.ConstraintLayout>

Media

vmap link : https://castqqq.free.beeceptor.com/test01

the main video has a token that has expired time.

Bug Report

marcbaechinger commented 2 years ago

This looks like a general Android UI challenge on various API levels for me that you need to solve in your app.

Can you narrow down the bug report in what you think is broken on the StyledPlayerView?

sajjadshahbazi commented 2 years ago

I don't know what more information you need?

I have two StyledPlayerView, one of them for the main video (id: playerView) and another for the play advertisement(id: playerAdView). before starting the main video I played an advertisement after that I init exoplayer of the main video and start playing the main video, After 10 seconds, I play the ad again, but in this situation playerAdView (for advertisement ) is displayed behind of playerView (the main video). I can't play a video over another video unless release an older player . I do know what things make that older StyledPlayerView play above another StyledPlayerView. in problem just happen in android 7.

I came to resolve this problem with change the visibility of StyledPlayerViews, but StyledPlayerView after every time gone and visible ,it automatically sets the bottom border for defualttimebar, which messes up the design.

<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/motionLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:keepScreenOn="true" android:layoutDirection="rtl" app:layoutDescription="@xml/activity_tv_media_player_scene" tools:context=".mediaPlayer.player.TvVideoPlayerActivity"> ... <com.google.android.exoplayer2.ui.StyledPlayerView android:id="@+id/playerView" android:layout_width="0dp" android:layout_height="0dp" android:background="@color/black" app:animation_enabled="false" app:controller_layout_id="@layout/exo_playback_control_view" app:hide_during_ads="true" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:resize_mode="fit" app:show_buffering="never" /> ... <com.google.android.exoplayer2.ui.StyledPlayerView android:id="@+id/playerAdView" android:layout_width="0dp" android:layout_height="0dp" android:background="@color/black" android:focusable="true" app:animation_enabled="false" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:resize_mode="fit" app:show_buffering="never" app:use_controller="false" /> ... </androidx.constraintlayout.widget.ConstraintLayout>

sajjadshahbazi commented 2 years ago

I need to control elevations of StyledPlayerViews or prevent changing bottom margin of defaulttimebar.

sajjadshahbazi commented 2 years ago

I even put StyledPlayerView of advertisement at the new fragment but still displaying behind of playerView (the main video) !!