mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 08:20: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
|
@Serializable
|
||||||
data class PreviewFrames(
|
data class PreviewFrames(
|
||||||
val urls: List<String>? = null,
|
val urls: List<String>,
|
||||||
val frameWidth: Int? = null,
|
val frameWidth: Int,
|
||||||
val frameHeight: Int? = null,
|
val frameHeight: Int,
|
||||||
val totalCount: Int? = null,
|
val totalCount: Int,
|
||||||
val durationPerFrame: Int? = null,
|
val durationPerFrame: Long,
|
||||||
val framesPerPageX: Int? = null,
|
val framesPerPageX: Int,
|
||||||
val framesPerPageY: Int? = null,
|
val framesPerPageY: Int
|
||||||
)
|
)
|
||||||
|
@ -93,12 +93,12 @@ class SeekbarPreviewListener(
|
|||||||
private fun getPreviewFrame(position: Long): PreviewFrame? {
|
private fun getPreviewFrame(position: Long): PreviewFrame? {
|
||||||
var startPosition: Long = 0
|
var startPosition: Long = 0
|
||||||
// get the frames with the best quality
|
// get the frames with the best quality
|
||||||
val frames = previewFrames.sortedBy { it.frameHeight }.lastOrNull()
|
val frames = previewFrames.maxByOrNull { it.frameHeight }
|
||||||
frames?.urls?.forEach { url ->
|
frames?.urls?.forEach { url ->
|
||||||
// iterate over all available positions and find the one matching the current position
|
// iterate over all available positions and find the one matching the current position
|
||||||
for (y in 0 until frames.framesPerPageY!!) {
|
for (y in 0 until frames.framesPerPageY) {
|
||||||
for (x in 0 until frames.framesPerPageX!!) {
|
for (x in 0 until frames.framesPerPageX) {
|
||||||
val endPosition = startPosition + frames.durationPerFrame!!.toLong()
|
val endPosition = startPosition + frames.durationPerFrame
|
||||||
if (position in startPosition until endPosition) {
|
if (position in startPosition until endPosition) {
|
||||||
return PreviewFrame(url, x, y, frames.framesPerPageX, frames.framesPerPageY)
|
return PreviewFrame(url, x, y, frames.framesPerPageX, frames.framesPerPageY)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user