package com.ux.video.file.filerecovery.photo

import java.io.File

import android.os.Parcelable
import com.ux.video.file.filerecovery.utils.Common
import kotlinx.parcelize.Parcelize

@Parcelize
data class ResultPhotosFiles(
    val name: String,
    val path: String? = null,
    val size: Long,          // 字节
    val sizeString: String,
    val lastModified: Long,   // 时间戳
    var resolution: String //  尺寸
) : Parcelable {
    val targetFile: File?
        get() = path?.let { File(it) }

    //是否为缩略图文件（宽高任一小于 256）
    val isThumbnail: Boolean
        get() {
            val parts = resolution.lowercase().split("*").mapNotNull {
                it.trim().toIntOrNull()
            }
            if (parts.size == 2) {
                val (width, height) = parts
                return width < 256 || height < 256
            }
            return false
        }


    //音视频时长
    val duration: Long
        get() {
            return Common.getMediaDuration(path.toString()) }
}
