[fix] Fix group redundant videos and jump logic

This commit is contained in:
acite
2025-09-27 15:07:55 +08:00
parent 4e346a83ee
commit 8184ab211c
4 changed files with 31 additions and 8 deletions

View File

@@ -82,7 +82,7 @@ fun HomeScreen(
{
updateRelate(homeScreenViewModel.recentManager.recentVideo, i)
val playList = mutableListOf("${i.klass}/${i.id}")
val playList = mutableListOf<String>()
val fv = homeScreenViewModel.videoLibrary.classesMap.map { it.value }.flatten()
val group = fv.filter { it.klass == i.klass && it.video.group == i.video.group }
@@ -90,7 +90,7 @@ fun HomeScreen(
playList.add("${i.klass}/${i.id}")
}
val route = "video_player_route/${playList.joinToString(",").toHex()}"
val route = "video_player_route/${(playList.joinToString(",") + "|${i.id}").toHex()}"
navController.navigate(route)
}, homeScreenViewModel.imageLoader!!)
HorizontalDivider(Modifier.padding(vertical = 8.dp).alpha(0.4f), 1.dp, DividerDefaults.color)

View File

@@ -150,7 +150,7 @@ private fun VideoDownloadCard(
jsonQuery.first { it.id == model.vid && it.klass == model.klass }
)
val playList = mutableListOf("${model.klass}/${model.vid}")
val playList = mutableListOf<String>()
val fv = viewModel.videoLibrary.classesMap.map { it.value }.flatten()
val video = fv.firstOrNull { it.klass == model.klass && it.id == model.vid }
@@ -161,7 +161,7 @@ private fun VideoDownloadCard(
}
}
val route = "video_player_route/${playList.joinToString(",").toHex()}"
val route = "video_player_route/${(playList.joinToString(",") + "|${model.vid}").toHex()}"
withContext(Dispatchers.Main) {
navigator.navigate(route)
}

View File

@@ -47,6 +47,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavHostController
import com.acitelight.aether.Global
import com.acitelight.aether.Global.updateRelate
import com.acitelight.aether.ToggleFullScreen
import com.acitelight.aether.viewModel.VideoPlayerViewModel
@@ -247,7 +248,16 @@ fun VideoPlayerPortal(
{
videoPlayerViewModel.isPlaying = false
videoPlayerViewModel.player?.pause()
val route = "video_player_route/${"${i.klass}/${i.id}".toHex()}"
val playList = mutableListOf<String>()
val fv = videoPlayerViewModel.videoLibrary.classesMap.map { it.value }.flatten()
val group = fv.filter { it.klass == i.klass && it.video.group == i.video.group }
for (i in group) {
playList.add("${i.klass}/${i.id}")
}
val route = "video_player_route/${playList.joinToString(",").toHex()}"
navController.navigate(route)
}, videoPlayerViewModel.imageLoader!!
)

View File

@@ -49,6 +49,7 @@ import androidx.media3.datasource.DefaultDataSource
import androidx.media3.exoplayer.trackselection.DefaultTrackSelector
import com.acitelight.aether.Global
import com.acitelight.aether.model.KeyImage
import com.acitelight.aether.service.VideoLibrary
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.first
@@ -56,7 +57,8 @@ import kotlinx.coroutines.flow.first
class VideoPlayerViewModel @Inject constructor(
@ApplicationContext private val context: Context,
val mediaManager: MediaManager,
val recentManager: RecentManager
val recentManager: RecentManager,
val videoLibrary: VideoLibrary,
) : ViewModel() {
var tabIndex by mutableIntStateOf(0)
var isPlaying by mutableStateOf(true)
@@ -100,7 +102,16 @@ class VideoPlayerViewModel @Inject constructor(
return
_init = true
val vs = videoId.hexToString().split(",").map { it.split("/") }.toMutableList()
val oId = videoId.hexToString()
var spec = "-1"
var vs = mutableListOf<List<String>>()
if(oId.contains("|"))
{
vs = oId.split("|")[0].split(",").map { it.split("/") }.toMutableList()
spec = oId.split("|")[1]
}
imageLoader = ImageLoader.Builder(context)
.components {
add(OkHttpNetworkFetcherFactory(createOkHttp()))
@@ -114,7 +125,9 @@ class VideoPlayerViewModel @Inject constructor(
videos = mediaManager.queryVideoBulk(vs.first()[0], vs.map { it[1] })!!
startPlay(
if (ix != null)
if(spec != "-1")
videos.first { it.id == spec}
else if (ix != null)
videos.first { it.id == ix.id }
else videos.first()
)