簡體   English   中英

ExoPlayer - 在整個音頻剪輯播放過程中顯示PlayerControlView

[英]ExoPlayer - Show PlayerControlView throughout playback of audio clip

我最近在我的Android項目中添加了ExoPlayer。 由於他們的網站,設置它和獲取音頻片段相對簡單。 我能夠從我的API獲取音頻文件並播放它,但問題是,播放開始后PlayerControlView消失了。 有沒有辦法可以強制PlayerControlView保持整個音頻剪輯播放? 這是包含PlayerControlView的片段的XML:

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".SetupWizard.NewHouseInformationFragment"
android:orientation="vertical">
<TextView android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="5dp"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    android:text="@string/why_join_a_house_string"
    android:fontFamily="sans-serif-light"
    android:textColor="@android:color/black"
    android:id = "@+id/HouseDescriptionTitleTextView"
    />
<TextView
    android:id = "@+id/WhyCreateHouseTitleTextView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textSize="18sp"
    android:fontFamily="sans-serif-medium"
    android:text="@string/why_create_house_string"
    android:textColor="@android:color/black"
    app:layout_constraintTop_toBottomOf="@id/HouseDescriptionTitleTextView"
    android:layout_margin="5dp"/>
<TextView
    android:fontFamily="sans-serif-light"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/manage_your_niche_network"
    android:drawableStart="@drawable/ic_check"
    android:drawablePadding="5dp"
    android:layout_margin="5dp"
    android:id = "@+id/CreateNicheNetworksTextView"
    android:textColor="@android:color/black"
    app:layout_constraintTop_toBottomOf="@id/WhyCreateHouseTitleTextView"/>
<TextView
    android:fontFamily="sans-serif-light"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textColor="@android:color/black"
    android:text="@string/share_content_string"
    android:drawableStart="@drawable/ic_check"
    android:drawablePadding="5dp"
    android:layout_margin="5dp"
    android:id = "@+id/ShareMultimediaTextView"
    app:layout_constraintTop_toBottomOf="@id/CreateNicheNetworksTextView"
    />
<TextView
    android:fontFamily="sans-serif-light"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textColor="@android:color/black"
    android:text="@string/send_broadcasts_messages"
    android:id = "@+id/SendBroadcastsTextView"
    android:layout_margin="5dp"
    android:drawableStart="@drawable/ic_check"
    android:drawablePadding="5dp"
    app:layout_constraintTop_toBottomOf="@id/ShareMultimediaTextView"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    />
<ImageView
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:id = "@+id/NewHouseContentImage"
    app:layout_constraintTop_toBottomOf="@id/FullControlTextView"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintVertical_weight="1"
    android:layout_margin="5dp"
    app:srcCompat = "@drawable/ic_chatting"
    android:adjustViewBounds="true"
    app:layout_constraintBottom_toTopOf="@id/CreateHousePlayerView"/>
<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/be_your_own_boss"
    android:textColor="@android:color/black"
    android:fontFamily="sans-serif-light"
    android:drawableStart="@drawable/ic_check"
    app:layout_constraintTop_toBottomOf="@id/SendBroadcastsTextView"
    android:layout_margin="5dp"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    android:drawablePadding="5dp"
    android:id = "@+id/FullControlTextView"/>
<com.google.android.exoplayer2.ui.PlayerControlView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="parent"
    android:id = "@+id/CreateHousePlayerView"
    android:layout_margin="5dp"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    />

仔細查看文檔后,我發現了以下信息:

在布局XML文件中使用時,可以在PlayerControlView上設置以下屬性:

show_timeout - 最后一次用戶交互與自動隱藏的控件之間的時間,以毫秒為單位。 如果控件不應自動超時,請使用零。

所以,我進入了我的PlayerControlView並將show_timeout屬性設置為零。 現在玩家控制視圖在一段時間后不會消失。

<com.google.android.exoplayer2.ui.PlayerControlView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:show_timeout="0"
    app:layout_constraintBottom_toBottomOf="parent"
    android:id = "@+id/CreateHousePlayerView"
    android:layout_margin="5dp"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toBottomOf="@id/NewHouseContentImage"
    />

資料來源: https//google.github.io/ExoPlayer/doc/reference/com/google/android/exoplayer2/ui/PlayerControlView.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM