mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 00:10:32 +05:30
Make PreviewFrames fields non-null.
This commit is contained in:
parent
854ba87fc5
commit
04facb03df
@ -4,11 +4,11 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class PreviewFrames(
|
||||
val urls: List<String>? = null,
|
||||
val frameWidth: Int? = null,
|
||||
val frameHeight: Int? = null,
|
||||
val totalCount: Int? = null,
|
||||
val durationPerFrame: Int? = null,
|
||||
val framesPerPageX: Int? = null,
|
||||
val framesPerPageY: Int? = null,
|
||||
val urls: List<String>,
|
||||
val frameWidth: Int,
|
||||
val frameHeight: Int,
|
||||
val totalCount: Int,
|
||||
val durationPerFrame: Long,
|
||||
val framesPerPageX: Int,
|
||||
val framesPerPageY: Int
|
||||
)
|
||||
|
@ -93,12 +93,12 @@ class SeekbarPreviewListener(
|
||||
private fun getPreviewFrame(position: Long): PreviewFrame? {
|
||||
var startPosition: Long = 0
|
||||
// get the frames with the best quality
|
||||
val frames = previewFrames.sortedBy { it.frameHeight }.lastOrNull()
|
||||
val frames = previewFrames.maxByOrNull { it.frameHeight }
|
||||
frames?.urls?.forEach { url ->
|
||||
// iterate over all available positions and find the one matching the current position
|
||||
for (y in 0 until frames.framesPerPageY!!) {
|
||||
for (x in 0 until frames.framesPerPageX!!) {
|
||||
val endPosition = startPosition + frames.durationPerFrame!!.toLong()
|
||||
for (y in 0 until frames.framesPerPageY) {
|
||||
for (x in 0 until frames.framesPerPageX) {
|
||||
val endPosition = startPosition + frames.durationPerFrame
|
||||
if (position in startPosition until endPosition) {
|
||||
return PreviewFrame(url, x, y, frames.framesPerPageX, frames.framesPerPageY)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user