Fix preview seek times in cut mode
This commit is contained in:
parent
2cd41421c2
commit
d90d8193e7
1 changed files with 4 additions and 9 deletions
|
|
@ -56,6 +56,7 @@ import kotlinx.coroutines.flow.flowOn
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import kotlin.math.max
|
||||||
|
|
||||||
|
|
||||||
class CutVideoBottomSheetDialog(private val _item: DownloadItem? = null, private val urls : String? = null, private var chapters: List<ChapterItem>? = null, private val listener: VideoCutListener? = null) : BottomSheetDialogFragment() {
|
class CutVideoBottomSheetDialog(private val _item: DownloadItem? = null, private val urls : String? = null, private var chapters: List<ChapterItem>? = null, private val listener: VideoCutListener? = null) : BottomSheetDialogFragment() {
|
||||||
|
|
@ -453,10 +454,7 @@ class CutVideoBottomSheetDialog(private val _item: DownloadItem? = null, private
|
||||||
val startTimestampString = startTimestamp.toStringTimeStamp()
|
val startTimestampString = startTimestamp.toStringTimeStamp()
|
||||||
val endTimestampString = endTimestamp.toStringTimeStamp()
|
val endTimestampString = endTimestamp.toStringTimeStamp()
|
||||||
|
|
||||||
var draggedFromBeginning = true
|
val draggedFromBeginning = rangeSlider.focusedThumbIndex != 1
|
||||||
if (toTextInput.text.toString() != endTimestampString){
|
|
||||||
draggedFromBeginning = false
|
|
||||||
}
|
|
||||||
|
|
||||||
fromTextInput.setTextAndRecalculateWidth(startTimestampString)
|
fromTextInput.setTextAndRecalculateWidth(startTimestampString)
|
||||||
toTextInput.setTextAndRecalculateWidth(endTimestampString)
|
toTextInput.setTextAndRecalculateWidth(endTimestampString)
|
||||||
|
|
@ -464,14 +462,11 @@ class CutVideoBottomSheetDialog(private val _item: DownloadItem? = null, private
|
||||||
|
|
||||||
okBtn.isEnabled = values[0] != 0F || values[1] != (itemDurationTimestamp / 1000).toFloat()
|
okBtn.isEnabled = values[0] != 0F || values[1] != (itemDurationTimestamp / 1000).toFloat()
|
||||||
|
|
||||||
val startpos = startTimestamp * 1000
|
|
||||||
try {
|
try {
|
||||||
if (draggedFromBeginning){
|
if (draggedFromBeginning){
|
||||||
player.seekTo(startpos)
|
player.seekTo(startTimestamp)
|
||||||
}else{
|
}else{
|
||||||
var endpos = (endTimestamp * 1000) - 1500
|
player.seekTo(max(startTimestamp, endTimestamp - 1500))
|
||||||
if (endpos < (startTimestamp * 1000)) endpos = startpos
|
|
||||||
player.seekTo(endpos)
|
|
||||||
}
|
}
|
||||||
player.play()
|
player.play()
|
||||||
}catch (ignored: Exception) {}
|
}catch (ignored: Exception) {}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue