aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt18
1 files changed, 10 insertions, 8 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt
index c45bf23d..d7f44420 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt
@@ -14,6 +14,7 @@ import ca.allanwang.kau.utils.AnimHolder
import ca.allanwang.kau.utils.dpToPx
import ca.allanwang.kau.utils.scaleXY
import ca.allanwang.kau.utils.toast
+import com.devbrackets.android.exomedia.ui.widget.VideoControls
import com.devbrackets.android.exomedia.ui.widget.VideoView
import com.pitchedapps.frost.R
import com.pitchedapps.frost.utils.L
@@ -78,7 +79,7 @@ class FrostVideoView @JvmOverloads constructor(
if (!isPlaying) showControls()
else viewerContract.onControlsHidden()
}
- }
+ }.start()
} else {
hideControls()
val (scale, tX, tY) = mapBounds()
@@ -89,7 +90,7 @@ class FrostVideoView @JvmOverloads constructor(
withAnimator(origScale, scale) { scaleXY = it }
withAnimator(origX, tX) { translationX = it }
withAnimator(origY, tY) { translationY = it }
- }
+ }.start()
}
}
@@ -144,7 +145,8 @@ class FrostVideoView @JvmOverloads constructor(
}
setOnTouchListener(FrameTouchListener(context))
v.setOnTouchListener(VideoTouchListener(context))
- setOnVideoSizedChangedListener { intrinsicWidth, intrinsicHeight ->
+ setOnVideoSizedChangedListener { intrinsicWidth, intrinsicHeight, pixelWidthHeightRatio ->
+ // todo use provided ratio?
val ratio = Math.min(width.toFloat() / intrinsicWidth, height.toFloat() / intrinsicHeight.toFloat())
/**
* Only remap if not expanded and if dimensions have changed
@@ -158,7 +160,7 @@ class FrostVideoView @JvmOverloads constructor(
fun setViewerContract(contract: FrostVideoViewerContract) {
this.viewerContract = contract
- videoControls?.setVisibilityListener(viewerContract)
+ (videoControls as? VideoControls)?.setVisibilityListener(viewerContract)
}
fun jumpToStart() {
@@ -186,7 +188,7 @@ class FrostVideoView @JvmOverloads constructor(
private fun hideControls() {
if (videoControls?.isVisible == true)
- videoControls?.hide()
+ videoControls?.hide(false)
}
private fun toggleControls() {
@@ -204,11 +206,11 @@ class FrostVideoView @JvmOverloads constructor(
fun destroy() {
stopPlayback()
if (alpha > 0f)
- ProgressAnimator.ofFloat(alpha, 0f) {
+ ProgressAnimator.ofFloat {
duration = FAST_ANIMATION_DURATION
- withAnimator { alpha = it }
+ withAnimator(alpha, 0f) { alpha = it }
withEndAction { onFinishedListener() }
- }
+ }.start()
else
onFinishedListener()
}