[feat] Complete video caching system
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
package com.acitelight.aether.model
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@Serializable
|
||||
data class Comment(
|
||||
val content: String,
|
||||
val username: String,
|
||||
|
||||
@@ -13,7 +13,9 @@ class DownloadItemState(
|
||||
progress: Int,
|
||||
status: Status,
|
||||
downloadedBytes: Long,
|
||||
totalBytes: Long
|
||||
totalBytes: Long,
|
||||
klass: String,
|
||||
vid: String
|
||||
) {
|
||||
var fileName by mutableStateOf(fileName)
|
||||
var filePath by mutableStateOf(filePath)
|
||||
@@ -22,4 +24,7 @@ class DownloadItemState(
|
||||
var status by mutableStateOf(status)
|
||||
var downloadedBytes by mutableStateOf(downloadedBytes)
|
||||
var totalBytes by mutableStateOf(totalBytes)
|
||||
|
||||
var klass by mutableStateOf(klass)
|
||||
var vid by mutableStateOf(vid)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.acitelight.aether.model
|
||||
|
||||
data class KeyImage(
|
||||
val name: String,
|
||||
val url: String,
|
||||
val key: String
|
||||
)
|
||||
|
||||
@@ -1,30 +1,59 @@
|
||||
package com.acitelight.aether.model
|
||||
|
||||
import com.acitelight.aether.service.ApiClient
|
||||
import kotlinx.serialization.Serializable
|
||||
import java.security.KeyPair
|
||||
|
||||
class Video constructor(
|
||||
|
||||
@Serializable
|
||||
class Video(
|
||||
val isLocal: Boolean,
|
||||
val localBase: String,
|
||||
val klass: String,
|
||||
val id: String,
|
||||
val token: String,
|
||||
val video: VideoResponse
|
||||
){
|
||||
fun getCover(): String
|
||||
{
|
||||
return "${ApiClient.getBase()}api/video/$klass/$id/cover?token=$token"
|
||||
) {
|
||||
fun getCover(): String {
|
||||
return if (isLocal)
|
||||
"$localBase/videos/$klass/$id/cover.jpg"
|
||||
else
|
||||
"${ApiClient.getBase()}api/video/$klass/$id/cover?token=$token"
|
||||
}
|
||||
|
||||
fun getVideo(): String
|
||||
{
|
||||
return "${ApiClient.getBase()}api/video/$klass/$id/av?token=$token"
|
||||
fun getVideo(): String {
|
||||
return if (isLocal)
|
||||
"$localBase/videos/$klass/$id/video.mp4"
|
||||
else
|
||||
"${ApiClient.getBase()}api/video/$klass/$id/av?token=$token"
|
||||
}
|
||||
|
||||
fun getGallery(): List<KeyImage>
|
||||
{
|
||||
return video.gallery.map{
|
||||
KeyImage(url = "${ApiClient.getBase()}api/video/$klass/$id/gallery/$it?token=$token", key = "$klass/$id/gallery/$it")
|
||||
fun getGallery(): List<KeyImage> {
|
||||
return if (isLocal)
|
||||
video.gallery.map {
|
||||
KeyImage(
|
||||
name = it,
|
||||
url = "$localBase/videos/$klass/$id/gallery/$it",
|
||||
key = "$klass/$id/gallery/$it"
|
||||
)
|
||||
} else video.gallery.map {
|
||||
KeyImage(
|
||||
name = it,
|
||||
url = "${ApiClient.getBase()}api/video/$klass/$id/gallery/$it?token=$token",
|
||||
key = "$klass/$id/gallery/$it"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun toLocal(localBase: String): Video
|
||||
{
|
||||
return Video(
|
||||
isLocal = true,
|
||||
localBase = localBase,
|
||||
klass = klass,
|
||||
id = id,
|
||||
token = "",
|
||||
video = video
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.acitelight.aether.model
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class VideoResponse(
|
||||
val name: String,
|
||||
val duration: Long,
|
||||
|
||||
Reference in New Issue
Block a user