[fix] Fix group redundant videos and jump logic
This commit is contained in:
@@ -82,7 +82,7 @@ fun HomeScreen(
|
|||||||
{
|
{
|
||||||
updateRelate(homeScreenViewModel.recentManager.recentVideo, i)
|
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 fv = homeScreenViewModel.videoLibrary.classesMap.map { it.value }.flatten()
|
||||||
|
|
||||||
val group = fv.filter { it.klass == i.klass && it.video.group == i.video.group }
|
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}")
|
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)
|
navController.navigate(route)
|
||||||
}, homeScreenViewModel.imageLoader!!)
|
}, homeScreenViewModel.imageLoader!!)
|
||||||
HorizontalDivider(Modifier.padding(vertical = 8.dp).alpha(0.4f), 1.dp, DividerDefaults.color)
|
HorizontalDivider(Modifier.padding(vertical = 8.dp).alpha(0.4f), 1.dp, DividerDefaults.color)
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ private fun VideoDownloadCard(
|
|||||||
jsonQuery.first { it.id == model.vid && it.klass == model.klass }
|
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 fv = viewModel.videoLibrary.classesMap.map { it.value }.flatten()
|
||||||
val video = fv.firstOrNull { it.klass == model.klass && it.id == model.vid }
|
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) {
|
withContext(Dispatchers.Main) {
|
||||||
navigator.navigate(route)
|
navigator.navigate(route)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import androidx.navigation.NavHostController
|
import androidx.navigation.NavHostController
|
||||||
import com.acitelight.aether.Global
|
import com.acitelight.aether.Global
|
||||||
|
import com.acitelight.aether.Global.updateRelate
|
||||||
import com.acitelight.aether.ToggleFullScreen
|
import com.acitelight.aether.ToggleFullScreen
|
||||||
import com.acitelight.aether.viewModel.VideoPlayerViewModel
|
import com.acitelight.aether.viewModel.VideoPlayerViewModel
|
||||||
|
|
||||||
@@ -247,7 +248,16 @@ fun VideoPlayerPortal(
|
|||||||
{
|
{
|
||||||
videoPlayerViewModel.isPlaying = false
|
videoPlayerViewModel.isPlaying = false
|
||||||
videoPlayerViewModel.player?.pause()
|
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)
|
navController.navigate(route)
|
||||||
}, videoPlayerViewModel.imageLoader!!
|
}, videoPlayerViewModel.imageLoader!!
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ import androidx.media3.datasource.DefaultDataSource
|
|||||||
import androidx.media3.exoplayer.trackselection.DefaultTrackSelector
|
import androidx.media3.exoplayer.trackselection.DefaultTrackSelector
|
||||||
import com.acitelight.aether.Global
|
import com.acitelight.aether.Global
|
||||||
import com.acitelight.aether.model.KeyImage
|
import com.acitelight.aether.model.KeyImage
|
||||||
|
import com.acitelight.aether.service.VideoLibrary
|
||||||
import kotlinx.coroutines.flow.filter
|
import kotlinx.coroutines.flow.filter
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
|
|
||||||
@@ -56,7 +57,8 @@ import kotlinx.coroutines.flow.first
|
|||||||
class VideoPlayerViewModel @Inject constructor(
|
class VideoPlayerViewModel @Inject constructor(
|
||||||
@ApplicationContext private val context: Context,
|
@ApplicationContext private val context: Context,
|
||||||
val mediaManager: MediaManager,
|
val mediaManager: MediaManager,
|
||||||
val recentManager: RecentManager
|
val recentManager: RecentManager,
|
||||||
|
val videoLibrary: VideoLibrary,
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
var tabIndex by mutableIntStateOf(0)
|
var tabIndex by mutableIntStateOf(0)
|
||||||
var isPlaying by mutableStateOf(true)
|
var isPlaying by mutableStateOf(true)
|
||||||
@@ -100,7 +102,16 @@ class VideoPlayerViewModel @Inject constructor(
|
|||||||
return
|
return
|
||||||
_init = true
|
_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)
|
imageLoader = ImageLoader.Builder(context)
|
||||||
.components {
|
.components {
|
||||||
add(OkHttpNetworkFetcherFactory(createOkHttp()))
|
add(OkHttpNetworkFetcherFactory(createOkHttp()))
|
||||||
@@ -114,7 +125,9 @@ class VideoPlayerViewModel @Inject constructor(
|
|||||||
videos = mediaManager.queryVideoBulk(vs.first()[0], vs.map { it[1] })!!
|
videos = mediaManager.queryVideoBulk(vs.first()[0], vs.map { it[1] })!!
|
||||||
|
|
||||||
startPlay(
|
startPlay(
|
||||||
if (ix != null)
|
if(spec != "-1")
|
||||||
|
videos.first { it.id == spec}
|
||||||
|
else if (ix != null)
|
||||||
videos.first { it.id == ix.id }
|
videos.first { it.id == ix.id }
|
||||||
else videos.first()
|
else videos.first()
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user