Show video controls always at the bottom

This commit is contained in:
Adolfo Santiago 2021-10-01 18:35:23 +02:00
parent d54974a18f
commit f6629fef7a
No known key found for this signature in database
GPG key ID: 244D6F9A317B4A65
2 changed files with 56 additions and 38 deletions

View file

@ -44,6 +44,7 @@ import com.keylesspalace.tusky.util.visible
import kotlinx.android.synthetic.main.activity_view_media.toolbar import kotlinx.android.synthetic.main.activity_view_media.toolbar
import kotlinx.android.synthetic.main.fragment_view_video.mediaDescription import kotlinx.android.synthetic.main.fragment_view_video.mediaDescription
import kotlinx.android.synthetic.main.fragment_view_video.progressBar import kotlinx.android.synthetic.main.fragment_view_video.progressBar
import kotlinx.android.synthetic.main.fragment_view_video.videoControls
import kotlinx.android.synthetic.main.fragment_view_video.videoView import kotlinx.android.synthetic.main.fragment_view_video.videoView
import timber.log.Timber import timber.log.Timber
@ -141,7 +142,8 @@ class ViewVideoFragment : ViewMediaFragment() {
player.prepare() player.prepare()
} }
videoView.requestFocus() videoControls.player = videoView.player
//videoView.requestFocus()
if(arguments!!.getBoolean(ARG_START_POSTPONED_TRANSITION)) { if(arguments!!.getBoolean(ARG_START_POSTPONED_TRANSITION)) {
mediaActivity.onBringUp() mediaActivity.onBringUp()
@ -237,6 +239,8 @@ class ViewVideoFragment : ViewMediaFragment() {
Player.STATE_READY, Player.STATE_READY,
Player.STATE_ENDED -> { Player.STATE_ENDED -> {
progressBar.visibility = View.GONE progressBar.visibility = View.GONE
videoControls.show()
videoControls.visibility = View.VISIBLE
} }
else -> { else -> {
} }

View file

@ -1,44 +1,58 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/videoContainer" android:id="@+id/videoContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:clickable="true" android:clickable="true"
android:focusable="true"> android:focusable="true">
<TextView <TextView
android:id="@+id/mediaDescription" android:id="@+id/mediaDescription"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="?attr/actionBarSize" android:layout_marginTop="?attr/actionBarSize"
android:background="#60000000" android:background="#60000000"
android:hyphenationFrequency="full" android:hyphenationFrequency="full"
android:lineSpacingMultiplier="1.1" android:lineSpacingMultiplier="1.1"
android:padding="8dp" android:padding="8dp"
android:textAlignment="center" android:textAlignment="center"
android:textColor="#eee" android:textColor="#eee"
android:textSize="?attr/status_text_medium" android:textSize="?attr/status_text_medium"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
tools:text="Some media description" /> tools:text="Some media description" />
<com.google.android.exoplayer2.ui.PlayerView <com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/videoView" android:id="@+id/videoView"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toTopOf="@id/videoControls"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toBottomOf="@id/mediaDescription"
app:resize_mode="fixed_width"
app:surface_type="surface_view"
app:use_controller="false" />
<ProgressBar <com.google.android.exoplayer2.ui.PlayerControlView
android:id="@+id/progressBar" android:id="@+id/videoControls"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent" android:visibility="gone"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintStart_toStartOf="parent"
app:show_timeout="0"
tools:visibility="visible" />
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>