Commit 4bd3f386 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy

Fix some video seek animation issues

parent 0a0048dd
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="m2.929,0.0017c-0.6332,0.039 -1.1271,0.5632 -1.1272,1.1975v21.5974c-0.0012,0.9329 1.0158,1.5103 1.8162,1.0311l17.998,-10.8011c0.7765,-0.4661 0.7765,-1.5914 0,-2.0575L3.618,0.1704c-0.2074,-0.1234 -0.4476,-0.1836 -0.689,-0.168z"
android:strokeAlpha="1"
android:strokeLineJoin="round"
android:strokeWidth="2.39972544"
android:fillColor="?attr/player_icon_color"
android:strokeColor="#00000000"
android:fillType="evenOdd"
android:fillAlpha="1"
android:strokeLineCap="butt"/>
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="m21.071,0.0017c0.6332,0.039 1.1271,0.5632 1.1272,1.1975v21.5974c0.0012,0.9329 -1.0158,1.5103 -1.8162,1.0311L2.3841,13.0266c-0.7765,-0.4661 -0.7765,-1.5914 0,-2.0575l17.998,-10.7987c0.2074,-0.1234 0.4476,-0.1836 0.689,-0.168z"
android:strokeAlpha="1"
android:strokeLineJoin="round"
android:strokeWidth="2.39972544"
android:fillColor="?attr/player_icon_color"
android:strokeColor="#00000000"
android:fillType="evenOdd"
android:fillAlpha="1"
android:strokeLineCap="butt"/>
</vector>
<?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:id="@+id/seekContainer"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/seekContainer"
android:layout_width="match_parent"
android:layout_height="match_parent">
......@@ -14,11 +14,11 @@
app:layout_constraintGuide_percent="0.5"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0"
android:id="@+id/seek_background"
android:background="@drawable/video_list_length_bg" />
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0"
android:id="@+id/seek_background"
android:background="@drawable/video_list_length_bg"/>
<org.videolan.vlc.gui.view.HalfCircleView
android:id="@+id/leftContainerBackground"
......@@ -45,26 +45,26 @@
app:layout_constraintTop_toTopOf="parent"/>
<com.google.android.material.circularreveal.CircularRevealFrameLayout
android:id="@+id/leftContainer"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginEnd="8dp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/guideline4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:id="@+id/leftContainer"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginEnd="8dp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/guideline4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<com.google.android.material.circularreveal.CircularRevealFrameLayout
android:id="@+id/rightContainer"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/guideline6"
app:layout_constraintTop_toTopOf="parent" />
android:id="@+id/rightContainer"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/guideline6"
app:layout_constraintTop_toTopOf="parent"/>
<!--<androidx.constraintlayout.widget.ConstraintLayout-->
<!--android:id="@+id/constraintLayout3"-->
......@@ -76,112 +76,136 @@
<!--app:layout_constraintStart_toStartOf="parent"-->
<!--app:layout_constraintTop_toTopOf="parent">-->
<ImageView
android:id="@+id/seekRewindSecond"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0"
app:srcCompat="@drawable/ic_half_seek_rewind"
app:layout_constraintEnd_toStartOf="@+id/seekRewindFirst"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="@+id/seekLeftText"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/guideline11"/>
<ImageView
android:id="@+id/seekRewindFirst"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0"
app:srcCompat="@drawable/ic_half_seek_rewind"
app:layout_constraintEnd_toEndOf="@+id/seekLeftText"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/seekRewindSecond"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/guideline11"/>
<TextView
android:id="@+id/seekLeftText"
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="8dp"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintTop_toTopOf="@+id/guideline11"
app:layout_constraintBottom_toBottomOf="@+id/guideline11"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline11"/>
<!--</androidx.constraintlayout.widget.ConstraintLayout>-->
android:id="@+id/seekLeftContainer">
<ImageView
android:id="@+id/seekRewindSecond"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0"
app:srcCompat="@drawable/ic_half_seek_rewind"
app:layout_constraintStart_toStartOf="@+id/seekLeftText"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintEnd_toStartOf="@+id/seekRewindFirst"
android:layout_marginTop="16dp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/seekLeftText"
app:layout_constraintHorizontal_chainStyle="packed"/>
<ImageView
android:id="@+id/seekRewindFirst"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0"
app:srcCompat="@drawable/ic_half_seek_rewind"
app:layout_constraintStart_toEndOf="@+id/seekRewindSecond"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintEnd_toEndOf="@+id/seekLeftText"
android:layout_marginTop="16dp"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/seekLeftText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/seekRewindSecond"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginTop="8dp"
android:layout_marginEnd="64dp"
android:layout_marginStart="32dp"
android:layout_marginBottom="8dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<!--<androidx.constraintlayout.widget.ConstraintLayout-->
<!--android:id="@+id/constraintLayout2"-->
<!--android:layout_width="0dp"-->
<!--android:layout_height="0dp"-->
<!--android:layout_marginEnd="2dp"-->
<!--app:layout_constraintBottom_toBottomOf="parent"-->
<!--app:layout_constraintEnd_toEndOf="parent"-->
<!--app:layout_constraintStart_toEndOf="@id/guideline6"-->
<!--app:layout_constraintTop_toTopOf="parent">-->
<ImageView
android:id="@+id/seekForwardFirst"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0"
app:srcCompat="@drawable/ic_half_seek_forward"
app:layout_constraintEnd_toStartOf="@+id/seekForwardSecond"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="@+id/seekRightText"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/guideline11"/>
<ImageView
android:id="@+id/seekForwardSecond"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0"
app:srcCompat="@drawable/ic_half_seek_forward"
app:layout_constraintEnd_toEndOf="@+id/seekRightText"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/seekForwardFirst"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/guideline11"/>
<TextView
android:id="@+id/seekRightText"
<!--</androidx.constraintlayout.widget.ConstraintLayout>-->
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="32dp"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintTop_toTopOf="@+id/guideline11"
app:layout_constraintBottom_toBottomOf="@+id/guideline11"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline11"/>
<!--</androidx.constraintlayout.widget.ConstraintLayout>-->
android:id="@+id/seekRightContainer">
<ImageView
android:id="@+id/seekForwardFirst"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0"
app:srcCompat="@drawable/ic_half_seek_forward"
app:layout_constraintHorizontal_chainStyle="packed"
android:layout_marginBottom="8dp"
app:layout_constraintEnd_toStartOf="@+id/seekForwardSecond"
app:layout_constraintStart_toStartOf="@+id/seekRightText"
app:layout_constraintBottom_toTopOf="@+id/seekRightText"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="16dp"
app:layout_constraintHorizontal_bias="0.5"/>
<ImageView
android:id="@+id/seekForwardSecond"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0"
app:srcCompat="@drawable/ic_half_seek_forward"
android:layout_marginTop="16dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toEndOf="@+id/seekForwardFirst"
app:layout_constraintEnd_toEndOf="@+id/seekRightText"
app:layout_constraintHorizontal_bias="0.5"
/>
<TextView
android:id="@+id/seekRightText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/seekForwardFirst"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginTop="8dp"
android:layout_marginEnd="32dp"
android:layout_marginBottom="8dp"
android:layout_marginStart="64dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline4"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintGuide_percent="0.3333333333"
app:layout_constraintTop_toTopOf="parent" />
android:id="@+id/guideline4"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintGuide_percent="0.3333333333"
app:layout_constraintTop_toTopOf="parent"/>
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.6666666666" />
android:id="@+id/guideline6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.6666666666"/>
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />
android:id="@+id/guideline7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -1973,6 +1973,7 @@ open class VideoPlayerActivity : AppCompatActivity(), IPlaybackSettingsControlle
private var nbTimesTaped = 0
private var lastSeekWasForward = true
private var seekAnimRunning = false
private var animatorSet: AnimatorSet = AnimatorSet()
internal fun seekDelta(delta: Int) {
service?.let { service ->
// unseekable stream
......@@ -1985,8 +1986,13 @@ open class VideoPlayerActivity : AppCompatActivity(), IPlaybackSettingsControlle
val sb = StringBuilder()
val seekForward = delta >= 0
initSeekOverlay()
if (lastSeekWasForward != seekForward) {
animatorSet.cancel()
hideSeekOverlay(true)
}
if (nbTimesTaped != 0 && lastSeekWasForward != seekForward) {
hideSeekOverlay()
nbTimesTaped = 0
}
......@@ -1998,7 +2004,6 @@ open class VideoPlayerActivity : AppCompatActivity(), IPlaybackSettingsControlle
.append(Tools.millisToString(service.time))
.append(')')
initSeekOverlay()
val container = if (seekForward) rightContainer else leftContainer
val containerBackground = if (seekForward) rightContainerBackground else leftContainerBackground
......@@ -2012,18 +2017,23 @@ open class VideoPlayerActivity : AppCompatActivity(), IPlaybackSettingsControlle
if (isTv) {
val seekTVConstraintSet = ConstraintSet()
seekTVConstraintSet.clone(seekContainer)
seekTVConstraintSet.clear(R.id.rightContainerBackground, ConstraintSet.START)
seekTVConstraintSet.constrainDefaultHeight(R.id.rightContainerBackground, ConstraintSet.MATCH_CONSTRAINT_WRAP)
seekTVConstraintSet.constrainHeight(R.id.rightContainerBackground, 175.dp)
seekTVConstraintSet.constrainWidth(R.id.rightContainerBackground, 300.dp)
seekTVConstraintSet.setMargin(R.id.seekRightText, ConstraintSet.END, 16.dp)
seekTVConstraintSet.clear(R.id.leftContainerBackground, ConstraintSet.END)
seekTVConstraintSet.constrainDefaultHeight(R.id.leftContainerBackground, ConstraintSet.MATCH_CONSTRAINT_WRAP)
seekTVConstraintSet.constrainHeight(R.id.leftContainerBackground, 175.dp)
seekTVConstraintSet.constrainWidth(R.id.leftContainerBackground, 300.dp)
seekTVConstraintSet.setMargin(R.id.seekLeftText, ConstraintSet.START, 16.dp)
seekRightText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22f)
seekLeftText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22f)
seekTVConstraintSet.connect(R.id.rightContainerBackground, ConstraintSet.START, R.id.seekRightContainer, ConstraintSet.START)
seekTVConstraintSet.connect(R.id.rightContainerBackground, ConstraintSet.TOP, R.id.seekRightContainer, ConstraintSet.TOP)
seekTVConstraintSet.connect(R.id.rightContainerBackground, ConstraintSet.BOTTOM, R.id.seekRightContainer, ConstraintSet.BOTTOM)
seekTVConstraintSet.setMargin(R.id.seekRightText, ConstraintSet.END, resources.getDimensionPixelSize(R.dimen.tv_overscan_horizontal))
seekTVConstraintSet.connect(R.id.leftContainerBackground, ConstraintSet.END, R.id.seekLeftContainer, ConstraintSet.END)
seekTVConstraintSet.connect(R.id.leftContainerBackground, ConstraintSet.TOP, R.id.seekLeftContainer, ConstraintSet.TOP)
seekTVConstraintSet.connect(R.id.leftContainerBackground, ConstraintSet.BOTTOM, R.id.seekLeftContainer, ConstraintSet.BOTTOM)
seekTVConstraintSet.setMargin(R.id.seekLeftText, ConstraintSet.START, resources.getDimensionPixelSize(R.dimen.tv_overscan_horizontal))
seekForwardFirst.setImageResource(R.drawable.ic_half_seek_forward_tv)
seekForwardSecond.setImageResource(R.drawable.ic_half_seek_forward_tv)
seekRewindFirst.setImageResource(R.drawable.ic_half_seek_rewind_tv)
seekRewindSecond.setImageResource(R.drawable.ic_half_seek_rewind_tv)
seekRightText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 28f)
seekLeftText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 28f)
seekTVConstraintSet.applyTo(seekContainer)
}
......@@ -2039,7 +2049,7 @@ open class VideoPlayerActivity : AppCompatActivity(), IPlaybackSettingsControlle
//the center is offset + the radius is 2 * the width to reveal an arc instead of half a circle
val cx = if (seekForward) container.width * 2 else -container.width
val cy = container.height / 2
val animatorSet = AnimatorSet()
animatorSet = AnimatorSet()
val circularReveal = CircularRevealCompat.createCircularReveal(container, cx.toFloat(), cy.toFloat(), 0F, container.width.toFloat() * 2)
val backgroundColorAnimator = ObjectAnimator.ofObject(container,
CircularRevealWidget.CircularRevealScrimColorProperty.CIRCULAR_REVEAL_SCRIM_COLOR.name,
......@@ -2047,10 +2057,10 @@ open class VideoPlayerActivity : AppCompatActivity(), IPlaybackSettingsControlle
Color.TRANSPARENT, ContextCompat.getColor(this, R.color.ripple_white), Color.TRANSPARENT)
val containerBackgroundAnim = ObjectAnimator.ofFloat(containerBackground, "alpha", 0f, 1f)
containerBackgroundAnim.duration = SEEK_TIMEOUT
containerBackgroundAnim.duration = 300
val textAnim = ObjectAnimator.ofFloat(textView, "alpha", 0f, 1f)
textAnim.duration = SEEK_TIMEOUT
textAnim.duration = 300
val anims: ArrayList<Animator> = arrayListOf(firstImageAnim, secondImageAnim)
if (!isTv) {
......@@ -2072,7 +2082,6 @@ open class VideoPlayerActivity : AppCompatActivity(), IPlaybackSettingsControlle
leftContainerBackground.animate().cancel()
animatorSet.playTogether(anims)
animatorSet.duration = 1000
val mainAnimOut = ObjectAnimator.ofFloat(seek_background, "alpha", 0f)
backgroundAnim.duration = 200
......@@ -2091,14 +2100,26 @@ open class VideoPlayerActivity : AppCompatActivity(), IPlaybackSettingsControlle
}
}
private fun hideSeekOverlay() {
private fun hideSeekOverlay(immediate: Boolean = false) {
if (BuildConfig.DEBUG) Log.d(this::class.java.simpleName, "hideSeekOverlay $immediate")
seekAnimRunning = false
rightContainer.visibility = View.INVISIBLE
leftContainer.visibility = View.INVISIBLE
seekRightText.animate().alpha(0f).withEndAction { seekRightText.text = "" }
seekLeftText.animate().alpha(0f).withEndAction { seekLeftText.text = "" }
rightContainerBackground.animate().alpha(0f)
leftContainerBackground.animate().alpha(0f)
if (immediate) {
seekRightText.animate().cancel()
seekLeftText.animate().cancel()
rightContainerBackground.animate().cancel()
leftContainerBackground.animate().cancel()
seekRightText.alpha = 0f
seekLeftText.alpha = 0f
rightContainerBackground.alpha = 0f
leftContainerBackground.alpha = 0f
} else {
seekRightText.animate().alpha(0f).withEndAction { seekRightText.text = "" }
seekLeftText.animate().alpha(0f).withEndAction { seekLeftText.text = "" }
rightContainerBackground.animate().alpha(0f)
leftContainerBackground.animate().alpha(0f)
}
nbTimesTaped = 0
seekForwardFirst.alpha = 0f
seekForwardSecond.alpha = 0f
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment