Fixes #13930 - Clamp Large videos to Max duration after Media quality change
This commit is contained in:
parent
28c280947f
commit
bce0f93abd
1 changed files with 10 additions and 2 deletions
|
@ -335,6 +335,14 @@ class MediaSelectionViewModel(
|
||||||
|
|
||||||
store.update { it.copy(quality = sentMediaQuality, isPreUploadEnabled = false) }
|
store.update { it.copy(quality = sentMediaQuality, isPreUploadEnabled = false) }
|
||||||
repository.uploadRepository.cancelAllUploads()
|
repository.uploadRepository.cancelAllUploads()
|
||||||
|
|
||||||
|
store.state.selectedMedia.forEach { mediaItem ->
|
||||||
|
if (MediaUtil.isVideoType(mediaItem.contentType) && MediaConstraints.isVideoTranscodeAvailable()) {
|
||||||
|
val uri = mediaItem.uri
|
||||||
|
val data = store.state.getOrCreateVideoTrimData(uri)
|
||||||
|
onEditVideoDuration(totalDurationUs = data.totalInputDurationUs, startTimeUs = data.startTimeUs, endTimeUs = data.endTimeUs, touchEnabled = true, uri = uri)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setMessage(text: CharSequence?) {
|
fun setMessage(text: CharSequence?) {
|
||||||
|
@ -345,9 +353,9 @@ class MediaSelectionViewModel(
|
||||||
store.update { it.copy(viewOnceToggleState = it.viewOnceToggleState.next()) }
|
store.update { it.copy(viewOnceToggleState = it.viewOnceToggleState.next()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onEditVideoDuration(totalDurationUs: Long, startTimeUs: Long, endTimeUs: Long, touchEnabled: Boolean) {
|
fun onEditVideoDuration(totalDurationUs: Long, startTimeUs: Long, endTimeUs: Long, touchEnabled: Boolean, uri: Uri? = store.state.focusedMedia?.uri) {
|
||||||
|
if (uri == null) return
|
||||||
store.update {
|
store.update {
|
||||||
val uri = it.focusedMedia?.uri ?: return@update it
|
|
||||||
val data = it.getOrCreateVideoTrimData(uri)
|
val data = it.getOrCreateVideoTrimData(uri)
|
||||||
val clampedStartTime = max(startTimeUs, 0)
|
val clampedStartTime = max(startTimeUs, 0)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue