Compare commits
1 Commits
dev-feat2
...
dev-optimi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
55fda08e06 |
@@ -5,7 +5,6 @@ import androidx.compose.material.icons.Icons
|
|||||||
import android.graphics.drawable.Icon
|
import android.graphics.drawable.Icon
|
||||||
import android.net.http.SslCertificate.saveState
|
import android.net.http.SslCertificate.saveState
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.WindowManager
|
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.activity.enableEdgeToEdge
|
import androidx.activity.enableEdgeToEdge
|
||||||
@@ -57,9 +56,6 @@ import com.acitelight.aether.view.VideoScreen
|
|||||||
class MainActivity : ComponentActivity() {
|
class MainActivity : ComponentActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
window.attributes = window.attributes.apply {
|
|
||||||
screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE
|
|
||||||
}
|
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||||
setContent {
|
setContent {
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
package com.acitelight.aether.view
|
package com.acitelight.aether.view
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
|
||||||
import android.content.pm.ActivityInfo
|
import android.content.pm.ActivityInfo
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.media.AudioManager
|
|
||||||
import androidx.activity.compose.BackHandler
|
import androidx.activity.compose.BackHandler
|
||||||
import androidx.compose.animation.AnimatedVisibility
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.animation.fadeIn
|
import androidx.compose.animation.fadeIn
|
||||||
@@ -14,6 +12,7 @@ import androidx.compose.animation.slideOutVertically
|
|||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Pause
|
import androidx.compose.material.icons.filled.Pause
|
||||||
import androidx.compose.material.icons.filled.PlayArrow
|
import androidx.compose.material.icons.filled.PlayArrow
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
@@ -51,10 +50,7 @@ import androidx.compose.foundation.lazy.LazyRow
|
|||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.icons.Icons
|
|
||||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||||
import androidx.compose.material.icons.automirrored.filled.VolumeUp
|
|
||||||
import androidx.compose.material.icons.filled.Brightness4
|
|
||||||
import androidx.compose.material.icons.filled.FastForward
|
import androidx.compose.material.icons.filled.FastForward
|
||||||
import androidx.compose.material.icons.filled.Fullscreen
|
import androidx.compose.material.icons.filled.Fullscreen
|
||||||
import androidx.compose.material.icons.filled.Info
|
import androidx.compose.material.icons.filled.Info
|
||||||
@@ -62,7 +58,6 @@ import androidx.compose.material.icons.filled.Share
|
|||||||
import androidx.compose.material.icons.filled.Star
|
import androidx.compose.material.icons.filled.Star
|
||||||
import androidx.compose.material.icons.filled.ThumbDown
|
import androidx.compose.material.icons.filled.ThumbDown
|
||||||
import androidx.compose.material.icons.filled.ThumbUp
|
import androidx.compose.material.icons.filled.ThumbUp
|
||||||
import androidx.compose.material.icons.filled.VolumeUp
|
|
||||||
import androidx.compose.material3.Card
|
import androidx.compose.material3.Card
|
||||||
import androidx.compose.material3.CardColors
|
import androidx.compose.material3.CardColors
|
||||||
import androidx.compose.material3.DividerDefaults
|
import androidx.compose.material3.DividerDefaults
|
||||||
@@ -73,8 +68,6 @@ import androidx.compose.material3.VerticalDivider
|
|||||||
import androidx.compose.material3.SliderDefaults
|
import androidx.compose.material3.SliderDefaults
|
||||||
import androidx.compose.material3.Tab
|
import androidx.compose.material3.Tab
|
||||||
import androidx.compose.material3.TabRow
|
import androidx.compose.material3.TabRow
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
|
||||||
import androidx.compose.runtime.derivedStateOf
|
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableFloatStateOf
|
import androidx.compose.runtime.mutableFloatStateOf
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
@@ -102,7 +95,6 @@ import com.acitelight.aether.Global
|
|||||||
import com.acitelight.aether.ToggleFullScreen
|
import com.acitelight.aether.ToggleFullScreen
|
||||||
import com.acitelight.aether.model.KeyImage
|
import com.acitelight.aether.model.KeyImage
|
||||||
import com.acitelight.aether.model.Video
|
import com.acitelight.aether.model.Video
|
||||||
import kotlin.math.abs
|
|
||||||
|
|
||||||
fun formatTime(ms: Long): String {
|
fun formatTime(ms: Long): String {
|
||||||
if (ms <= 0) return "00:00:00"
|
if (ms <= 0) return "00:00:00"
|
||||||
@@ -231,18 +223,6 @@ fun PortalCorePlayer(modifier: Modifier, videoPlayerViewModel: VideoPlayerViewMo
|
|||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val activity = context as? Activity
|
val activity = context as? Activity
|
||||||
|
|
||||||
val audioManager = remember { context.getSystemService(Context.AUDIO_SERVICE) as AudioManager }
|
|
||||||
val maxVolume = remember { audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC) }
|
|
||||||
var volFactor by remember { mutableFloatStateOf(audioManager.getStreamVolume(AudioManager.STREAM_MUSIC).toFloat() / maxVolume.toFloat()) }
|
|
||||||
|
|
||||||
fun setVolume(value: Int) {
|
|
||||||
audioManager.setStreamVolume(
|
|
||||||
AudioManager.STREAM_MUSIC,
|
|
||||||
value.coerceIn(0, maxVolume),
|
|
||||||
AudioManager.FLAG_PLAY_SOUND
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
Box(modifier)
|
Box(modifier)
|
||||||
{
|
{
|
||||||
AndroidView(
|
AndroidView(
|
||||||
@@ -259,53 +239,19 @@ fun PortalCorePlayer(modifier: Modifier, videoPlayerViewModel: VideoPlayerViewMo
|
|||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.pointerInput(Unit) {
|
.pointerInput(Unit) {
|
||||||
detectDragGestures(
|
detectDragGestures(
|
||||||
onDragStart = { offset ->
|
onDragStart = {
|
||||||
if(offset.x < size.width / 2)
|
videoPlayerViewModel.dragging = true
|
||||||
{
|
videoPlayerViewModel.planeVisibility = true
|
||||||
videoPlayerViewModel.draggingPurpose = -1;
|
exoPlayer.pause()
|
||||||
}else{
|
|
||||||
videoPlayerViewModel.draggingPurpose = -2;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onDragEnd = {
|
onDragEnd = {
|
||||||
if (videoPlayerViewModel.isPlaying && videoPlayerViewModel.draggingPurpose == 0)
|
videoPlayerViewModel.dragging = false
|
||||||
|
if (videoPlayerViewModel.isPlaying)
|
||||||
exoPlayer.play()
|
exoPlayer.play()
|
||||||
|
|
||||||
videoPlayerViewModel.draggingPurpose = -1;
|
|
||||||
},
|
},
|
||||||
onDrag = { change, dragAmount ->
|
onDrag = { change, dragAmount ->
|
||||||
if(abs(dragAmount.x) > abs(dragAmount.y) &&
|
exoPlayer.seekTo((exoPlayer.currentPosition + dragAmount.x * 200.0f).toLong())
|
||||||
(videoPlayerViewModel.draggingPurpose == -1 || videoPlayerViewModel.draggingPurpose == -2))
|
videoPlayerViewModel.playProcess = exoPlayer.currentPosition.toFloat() / exoPlayer.duration.toFloat()
|
||||||
{
|
|
||||||
videoPlayerViewModel.draggingPurpose = 0
|
|
||||||
videoPlayerViewModel.planeVisibility = true
|
|
||||||
exoPlayer.pause()
|
|
||||||
}
|
|
||||||
else if(videoPlayerViewModel.draggingPurpose == -1) videoPlayerViewModel.draggingPurpose = 1
|
|
||||||
else if(videoPlayerViewModel.draggingPurpose == -2) videoPlayerViewModel.draggingPurpose = 2
|
|
||||||
|
|
||||||
if(videoPlayerViewModel.draggingPurpose == 0)
|
|
||||||
{
|
|
||||||
exoPlayer.seekTo((exoPlayer.currentPosition + dragAmount.x * 200.0f).toLong())
|
|
||||||
videoPlayerViewModel.playProcess = exoPlayer.currentPosition.toFloat() / exoPlayer.duration.toFloat()
|
|
||||||
}else if(videoPlayerViewModel.draggingPurpose == 2)
|
|
||||||
{
|
|
||||||
val cu = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC)
|
|
||||||
volFactor = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC).toFloat() / maxVolume.toFloat()
|
|
||||||
if(dragAmount.y < 0)
|
|
||||||
setVolume( cu + 1);
|
|
||||||
else if(dragAmount.y > 0)
|
|
||||||
setVolume( cu - 1);
|
|
||||||
}else if(videoPlayerViewModel.draggingPurpose == 1)
|
|
||||||
{
|
|
||||||
videoPlayerViewModel.brit = (videoPlayerViewModel.brit - dragAmount.y * 0.002f).coerceIn(0f, 1f);
|
|
||||||
|
|
||||||
activity?.window?.attributes = activity.window.attributes.apply {
|
|
||||||
screenBrightness = videoPlayerViewModel.brit.coerceIn(0f, 1f)
|
|
||||||
}
|
|
||||||
activity?.window?.setAttributes(activity.window.attributes)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -366,7 +312,7 @@ fun PortalCorePlayer(modifier: Modifier, videoPlayerViewModel: VideoPlayerViewMo
|
|||||||
}
|
}
|
||||||
|
|
||||||
androidx.compose.animation.AnimatedVisibility(
|
androidx.compose.animation.AnimatedVisibility(
|
||||||
visible = videoPlayerViewModel.draggingPurpose == 0,
|
visible = videoPlayerViewModel.dragging,
|
||||||
enter = fadeIn(
|
enter = fadeIn(
|
||||||
initialAlpha = 0f,
|
initialAlpha = 0f,
|
||||||
),
|
),
|
||||||
@@ -374,8 +320,7 @@ fun PortalCorePlayer(modifier: Modifier, videoPlayerViewModel: VideoPlayerViewMo
|
|||||||
targetAlpha = 0f
|
targetAlpha = 0f
|
||||||
),
|
),
|
||||||
modifier = Modifier.align(Alignment.Center)
|
modifier = Modifier.align(Alignment.Center)
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
Text(
|
Text(
|
||||||
text = "${formatTime((exoPlayer.duration * videoPlayerViewModel.playProcess).toLong())}/${
|
text = "${formatTime((exoPlayer.duration * videoPlayerViewModel.playProcess).toLong())}/${
|
||||||
formatTime(
|
formatTime(
|
||||||
@@ -383,74 +328,12 @@ fun PortalCorePlayer(modifier: Modifier, videoPlayerViewModel: VideoPlayerViewMo
|
|||||||
)
|
)
|
||||||
}",
|
}",
|
||||||
fontWeight = FontWeight.Bold,
|
fontWeight = FontWeight.Bold,
|
||||||
modifier = Modifier.padding(bottom = 12.dp),
|
modifier = Modifier
|
||||||
|
.padding(bottom = 12.dp),
|
||||||
fontSize = 18.sp
|
fontSize = 18.sp
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
androidx.compose.animation.AnimatedVisibility(
|
|
||||||
visible = videoPlayerViewModel.draggingPurpose == 2,
|
|
||||||
enter = fadeIn(
|
|
||||||
initialAlpha = 0f,
|
|
||||||
),
|
|
||||||
exit = fadeOut(
|
|
||||||
targetAlpha = 0f
|
|
||||||
),
|
|
||||||
modifier = Modifier.align(Alignment.Center)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
Row(Modifier.background(Color(0x88000000), RoundedCornerShape(18)).width(200.dp))
|
|
||||||
{
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.AutoMirrored.Filled.VolumeUp,
|
|
||||||
contentDescription = "Vol",
|
|
||||||
tint = Color.White,
|
|
||||||
modifier = Modifier.size(48.dp).padding(8.dp)
|
|
||||||
.align(Alignment.CenterVertically)
|
|
||||||
)
|
|
||||||
BiliMiniSlider(
|
|
||||||
value = volFactor,
|
|
||||||
onValueChange = {},
|
|
||||||
modifier = Modifier
|
|
||||||
.height(4.dp)
|
|
||||||
.padding(horizontal = 8.dp)
|
|
||||||
.align(Alignment.CenterVertically)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
androidx.compose.animation.AnimatedVisibility(
|
|
||||||
visible = videoPlayerViewModel.draggingPurpose == 1,
|
|
||||||
enter = fadeIn(
|
|
||||||
initialAlpha = 0f,
|
|
||||||
),
|
|
||||||
exit = fadeOut(
|
|
||||||
targetAlpha = 0f
|
|
||||||
),
|
|
||||||
modifier = Modifier.align(Alignment.Center)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
Row(Modifier.background(Color(0x88000000), RoundedCornerShape(18)).width(200.dp))
|
|
||||||
{
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Default.Brightness4,
|
|
||||||
contentDescription = "Brightness",
|
|
||||||
tint = Color.White,
|
|
||||||
modifier = Modifier.size(48.dp).padding(8.dp)
|
|
||||||
.align(Alignment.CenterVertically)
|
|
||||||
)
|
|
||||||
BiliMiniSlider(
|
|
||||||
value = videoPlayerViewModel.brit,
|
|
||||||
onValueChange = {},
|
|
||||||
modifier = Modifier
|
|
||||||
.height(4.dp)
|
|
||||||
.padding(horizontal = 8.dp)
|
|
||||||
.align(Alignment.CenterVertically)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(cover > 0.0f)
|
if(cover > 0.0f)
|
||||||
Spacer(Modifier.background(Color(0x00FF6699 - 0x00222222 + ((0x000000FF * cover).toLong() shl 24) )).fillMaxSize())
|
Spacer(Modifier.background(Color(0x00FF6699 - 0x00222222 + ((0x000000FF * cover).toLong() shl 24) )).fillMaxSize())
|
||||||
|
|
||||||
@@ -488,13 +371,7 @@ fun PortalCorePlayer(modifier: Modifier, videoPlayerViewModel: VideoPlayerViewMo
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(horizontal = 2.dp)
|
.padding(horizontal = 2.dp)
|
||||||
.align(Alignment.BottomCenter).background(
|
.align(Alignment.BottomCenter),
|
||||||
brush = Brush.verticalGradient(
|
|
||||||
colors = listOf(
|
|
||||||
Color.Transparent,
|
|
||||||
Color.Black.copy(alpha = 0.4f),
|
|
||||||
)
|
|
||||||
)),
|
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
) {
|
) {
|
||||||
IconButton(
|
IconButton(
|
||||||
@@ -836,18 +713,6 @@ fun VideoPlayerLandscape(videoPlayerViewModel: VideoPlayerViewModel)
|
|||||||
val activity = context as? Activity
|
val activity = context as? Activity
|
||||||
val exoPlayer: ExoPlayer = videoPlayerViewModel._player!!;
|
val exoPlayer: ExoPlayer = videoPlayerViewModel._player!!;
|
||||||
|
|
||||||
val audioManager = remember { context.getSystemService(Context.AUDIO_SERVICE) as AudioManager }
|
|
||||||
val maxVolume = remember { audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC) }
|
|
||||||
var volFactor by remember { mutableFloatStateOf(audioManager.getStreamVolume(AudioManager.STREAM_MUSIC).toFloat() / maxVolume.toFloat()) }
|
|
||||||
|
|
||||||
fun setVolume(value: Int) {
|
|
||||||
audioManager.setStreamVolume(
|
|
||||||
AudioManager.STREAM_MUSIC,
|
|
||||||
value.coerceIn(0, maxVolume),
|
|
||||||
AudioManager.FLAG_PLAY_SOUND
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
BackHandler {
|
BackHandler {
|
||||||
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||||
}
|
}
|
||||||
@@ -873,53 +738,19 @@ fun VideoPlayerLandscape(videoPlayerViewModel: VideoPlayerViewModel)
|
|||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.pointerInput(Unit) {
|
.pointerInput(Unit) {
|
||||||
detectDragGestures(
|
detectDragGestures(
|
||||||
onDragStart = { offset ->
|
onDragStart = {
|
||||||
if(offset.x < size.width / 2)
|
videoPlayerViewModel.planeVisibility = true
|
||||||
{
|
videoPlayerViewModel.dragging = true;
|
||||||
videoPlayerViewModel.draggingPurpose = -1;
|
exoPlayer.pause()
|
||||||
}else{
|
|
||||||
videoPlayerViewModel.draggingPurpose = -2;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onDragEnd = {
|
onDragEnd = {
|
||||||
if (videoPlayerViewModel.isPlaying && videoPlayerViewModel.draggingPurpose == 0)
|
videoPlayerViewModel.dragging = false;
|
||||||
|
if (videoPlayerViewModel.isPlaying)
|
||||||
exoPlayer.play()
|
exoPlayer.play()
|
||||||
|
|
||||||
videoPlayerViewModel.draggingPurpose = -1;
|
|
||||||
},
|
},
|
||||||
onDrag = { change, dragAmount ->
|
onDrag = { change, dragAmount ->
|
||||||
if(abs(dragAmount.x) > abs(dragAmount.y) &&
|
exoPlayer.seekTo((exoPlayer.currentPosition + dragAmount.x * 200.0f).toLong())
|
||||||
(videoPlayerViewModel.draggingPurpose == -1 || videoPlayerViewModel.draggingPurpose == -2))
|
videoPlayerViewModel.playProcess = exoPlayer.currentPosition.toFloat() / exoPlayer.duration.toFloat()
|
||||||
{
|
|
||||||
videoPlayerViewModel.draggingPurpose = 0
|
|
||||||
videoPlayerViewModel.planeVisibility = true
|
|
||||||
exoPlayer.pause()
|
|
||||||
}
|
|
||||||
else if(videoPlayerViewModel.draggingPurpose == -1) videoPlayerViewModel.draggingPurpose = 1
|
|
||||||
else if(videoPlayerViewModel.draggingPurpose == -2) videoPlayerViewModel.draggingPurpose = 2
|
|
||||||
|
|
||||||
if(videoPlayerViewModel.draggingPurpose == 0)
|
|
||||||
{
|
|
||||||
exoPlayer.seekTo((exoPlayer.currentPosition + dragAmount.x * 200.0f).toLong())
|
|
||||||
videoPlayerViewModel.playProcess = exoPlayer.currentPosition.toFloat() / exoPlayer.duration.toFloat()
|
|
||||||
}else if(videoPlayerViewModel.draggingPurpose == 2)
|
|
||||||
{
|
|
||||||
val cu = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC)
|
|
||||||
volFactor = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC).toFloat() / maxVolume.toFloat()
|
|
||||||
if(dragAmount.y < 0)
|
|
||||||
setVolume( cu + 1);
|
|
||||||
else if(dragAmount.y > 0)
|
|
||||||
setVolume( cu - 1);
|
|
||||||
}else if(videoPlayerViewModel.draggingPurpose == 1)
|
|
||||||
{
|
|
||||||
videoPlayerViewModel.brit = (videoPlayerViewModel.brit - dragAmount.y * 0.002f).coerceIn(0f, 1f);
|
|
||||||
|
|
||||||
activity?.window?.attributes = activity.window.attributes.apply {
|
|
||||||
screenBrightness = videoPlayerViewModel.brit.coerceIn(0f, 1f)
|
|
||||||
}
|
|
||||||
activity?.window?.setAttributes(activity.window.attributes)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -951,7 +782,7 @@ fun VideoPlayerLandscape(videoPlayerViewModel: VideoPlayerViewModel)
|
|||||||
)
|
)
|
||||||
|
|
||||||
androidx.compose.animation.AnimatedVisibility(
|
androidx.compose.animation.AnimatedVisibility(
|
||||||
visible = videoPlayerViewModel.draggingPurpose == 0,
|
visible = videoPlayerViewModel.dragging,
|
||||||
enter = fadeIn(
|
enter = fadeIn(
|
||||||
initialAlpha = 0f,
|
initialAlpha = 0f,
|
||||||
),
|
),
|
||||||
@@ -959,8 +790,7 @@ fun VideoPlayerLandscape(videoPlayerViewModel: VideoPlayerViewModel)
|
|||||||
targetAlpha = 0f
|
targetAlpha = 0f
|
||||||
),
|
),
|
||||||
modifier = Modifier.align(Alignment.Center)
|
modifier = Modifier.align(Alignment.Center)
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
Text(
|
Text(
|
||||||
text = "${formatTime((exoPlayer.duration * videoPlayerViewModel.playProcess).toLong())}/${
|
text = "${formatTime((exoPlayer.duration * videoPlayerViewModel.playProcess).toLong())}/${
|
||||||
formatTime(
|
formatTime(
|
||||||
@@ -973,68 +803,6 @@ fun VideoPlayerLandscape(videoPlayerViewModel: VideoPlayerViewModel)
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
androidx.compose.animation.AnimatedVisibility(
|
|
||||||
visible = videoPlayerViewModel.draggingPurpose == 2,
|
|
||||||
enter = fadeIn(
|
|
||||||
initialAlpha = 0f,
|
|
||||||
),
|
|
||||||
exit = fadeOut(
|
|
||||||
targetAlpha = 0f
|
|
||||||
),
|
|
||||||
modifier = Modifier.align(Alignment.Center)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
Row(Modifier.background(Color(0x88000000), RoundedCornerShape(18)).width(200.dp))
|
|
||||||
{
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.AutoMirrored.Filled.VolumeUp,
|
|
||||||
contentDescription = "Vol",
|
|
||||||
tint = Color.White,
|
|
||||||
modifier = Modifier.size(48.dp).padding(8.dp)
|
|
||||||
.align(Alignment.CenterVertically)
|
|
||||||
)
|
|
||||||
BiliMiniSlider(
|
|
||||||
value = volFactor,
|
|
||||||
onValueChange = {},
|
|
||||||
modifier = Modifier
|
|
||||||
.height(4.dp)
|
|
||||||
.padding(horizontal = 8.dp)
|
|
||||||
.align(Alignment.CenterVertically)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
androidx.compose.animation.AnimatedVisibility(
|
|
||||||
visible = videoPlayerViewModel.draggingPurpose == 1,
|
|
||||||
enter = fadeIn(
|
|
||||||
initialAlpha = 0f,
|
|
||||||
),
|
|
||||||
exit = fadeOut(
|
|
||||||
targetAlpha = 0f
|
|
||||||
),
|
|
||||||
modifier = Modifier.align(Alignment.Center)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
Row(Modifier.background(Color(0x88000000), RoundedCornerShape(18)).width(200.dp))
|
|
||||||
{
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Default.Brightness4,
|
|
||||||
contentDescription = "Brightness",
|
|
||||||
tint = Color.White,
|
|
||||||
modifier = Modifier.size(48.dp).padding(8.dp)
|
|
||||||
.align(Alignment.CenterVertically)
|
|
||||||
)
|
|
||||||
BiliMiniSlider(
|
|
||||||
value = videoPlayerViewModel.brit,
|
|
||||||
onValueChange = {},
|
|
||||||
modifier = Modifier
|
|
||||||
.height(4.dp)
|
|
||||||
.padding(horizontal = 8.dp)
|
|
||||||
.align(Alignment.CenterVertically)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AnimatedVisibility(
|
AnimatedVisibility(
|
||||||
visible = videoPlayerViewModel.isLongPressing,
|
visible = videoPlayerViewModel.isLongPressing,
|
||||||
enter = slideInVertically(initialOffsetY = { fullHeight -> -fullHeight }),
|
enter = slideInVertically(initialOffsetY = { fullHeight -> -fullHeight }),
|
||||||
@@ -1064,50 +832,21 @@ fun VideoPlayerLandscape(videoPlayerViewModel: VideoPlayerViewModel)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimatedVisibility(
|
IconButton(
|
||||||
visible = videoPlayerViewModel.planeVisibility,
|
onClick = {
|
||||||
enter = slideInVertically(initialOffsetY = { fullHeight -> -fullHeight }),
|
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||||
exit = slideOutVertically(targetOffsetY = { fullHeight -> -fullHeight }),
|
},
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.align(Alignment.TopCenter)
|
|
||||||
.fillMaxWidth()
|
|
||||||
)
|
|
||||||
{
|
|
||||||
Row(Modifier
|
|
||||||
.align(Alignment.TopStart)
|
.align(Alignment.TopStart)
|
||||||
.padding(horizontal = 32.dp).background(
|
.padding(8.dp)
|
||||||
brush = Brush.verticalGradient(
|
) {
|
||||||
colors = listOf(
|
Icon(
|
||||||
Color.Black.copy(alpha = 0.4f),
|
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
|
||||||
Color.Transparent,
|
contentDescription = "Back",
|
||||||
)
|
tint = Color.White
|
||||||
)))
|
)
|
||||||
{
|
|
||||||
IconButton(
|
|
||||||
onClick = {
|
|
||||||
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
|
||||||
},
|
|
||||||
modifier = Modifier.size(36.dp).align(Alignment.CenterVertically)
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
modifier = Modifier.size(36.dp),
|
|
||||||
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
|
|
||||||
contentDescription = "Back",
|
|
||||||
tint = Color.White
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
Text(
|
|
||||||
text = "${videoPlayerViewModel.video?.video?.name}",
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
modifier = Modifier.padding(horizontal = 12.dp).align(Alignment.CenterVertically),
|
|
||||||
fontSize = 18.sp
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AnimatedVisibility(
|
AnimatedVisibility(
|
||||||
visible = videoPlayerViewModel.planeVisibility,
|
visible = videoPlayerViewModel.planeVisibility,
|
||||||
enter = slideInVertically(initialOffsetY = { fullHeight -> fullHeight }),
|
enter = slideInVertically(initialOffsetY = { fullHeight -> fullHeight }),
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.acitelight.aether.view
|
package com.acitelight.aether.view
|
||||||
|
|
||||||
import android.R.id.tabs
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
@@ -20,12 +19,7 @@ import androidx.compose.foundation.lazy.grid.items
|
|||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material3.Card
|
import androidx.compose.material3.Card
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.MaterialTheme
|
|
||||||
import androidx.compose.material3.PrimaryScrollableTabRow
|
|
||||||
import androidx.compose.material3.Tab
|
import androidx.compose.material3.Tab
|
||||||
import androidx.compose.material3.TabRow
|
|
||||||
import androidx.compose.material3.TabRowDefaults
|
|
||||||
import androidx.compose.material3.TabRowDefaults.tabIndicatorOffset
|
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
@@ -39,19 +33,16 @@ import androidx.compose.ui.unit.sp
|
|||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import coil3.compose.AsyncImage
|
import coil3.compose.AsyncImage
|
||||||
import com.acitelight.aether.model.Video
|
import com.acitelight.aether.model.Video
|
||||||
import com.acitelight.aether.service.MediaManager
|
|
||||||
import com.acitelight.aether.viewModel.VideoScreenViewModel
|
import com.acitelight.aether.viewModel.VideoScreenViewModel
|
||||||
import androidx.compose.material3.PrimaryTabRow
|
|
||||||
import androidx.compose.material3.ScrollableTabRow
|
import androidx.compose.material3.ScrollableTabRow
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.mutableStateListOf
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.graphics.Brush
|
import androidx.compose.ui.graphics.Brush
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
|
||||||
import androidx.navigation.NavHostController
|
import androidx.navigation.NavHostController
|
||||||
import coil3.request.ImageRequest
|
import coil3.request.ImageRequest
|
||||||
import com.acitelight.aether.Global
|
import com.acitelight.aether.Global
|
||||||
import kotlinx.coroutines.flow.first
|
|
||||||
import java.nio.charset.Charset
|
import java.nio.charset.Charset
|
||||||
|
|
||||||
fun String.toHex(): String {
|
fun String.toHex(): String {
|
||||||
@@ -72,6 +63,7 @@ fun String.hexToString(charset: Charset = Charsets.UTF_8): String {
|
|||||||
@Composable
|
@Composable
|
||||||
fun VideoScreen(videoScreenViewModel: VideoScreenViewModel = viewModel(), navController: NavHostController)
|
fun VideoScreen(videoScreenViewModel: VideoScreenViewModel = viewModel(), navController: NavHostController)
|
||||||
{
|
{
|
||||||
|
val tabIndex by videoScreenViewModel.tabIndex;
|
||||||
videoScreenViewModel.SetupClient()
|
videoScreenViewModel.SetupClient()
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
@@ -86,8 +78,11 @@ fun VideoScreen(videoScreenViewModel: VideoScreenViewModel = viewModel(), navCon
|
|||||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
items(videoScreenViewModel.videos) { video ->
|
if(videoScreenViewModel.classes.isNotEmpty())
|
||||||
VideoCard(video, navController, videoScreenViewModel)
|
{
|
||||||
|
items(videoScreenViewModel.classesMap[videoScreenViewModel.classes[tabIndex]] ?: mutableStateListOf()) { video ->
|
||||||
|
VideoCard(video, navController, videoScreenViewModel)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,12 +93,11 @@ fun VideoScreen(videoScreenViewModel: VideoScreenViewModel = viewModel(), navCon
|
|||||||
fun TopRow(videoScreenViewModel: VideoScreenViewModel)
|
fun TopRow(videoScreenViewModel: VideoScreenViewModel)
|
||||||
{
|
{
|
||||||
val tabIndex by videoScreenViewModel.tabIndex;
|
val tabIndex by videoScreenViewModel.tabIndex;
|
||||||
val klasses by videoScreenViewModel.klasses.collectAsState();
|
|
||||||
|
|
||||||
if(klasses.isEmpty()) return
|
if(videoScreenViewModel.classes.isEmpty()) return
|
||||||
|
|
||||||
ScrollableTabRow (selectedTabIndex = tabIndex) {
|
ScrollableTabRow (selectedTabIndex = tabIndex) {
|
||||||
klasses.forEachIndexed { index, title ->
|
videoScreenViewModel.classes.forEachIndexed { index, title ->
|
||||||
Tab(
|
Tab(
|
||||||
selected = tabIndex == index,
|
selected = tabIndex == index,
|
||||||
onClick = { videoScreenViewModel.setTabIndex(index) },
|
onClick = { videoScreenViewModel.setTabIndex(index) },
|
||||||
@@ -115,13 +109,14 @@ fun TopRow(videoScreenViewModel: VideoScreenViewModel)
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun VideoCard(video: Video, navController: NavHostController, videoScreenViewModel: VideoScreenViewModel) {
|
fun VideoCard(video: Video, navController: NavHostController, videoScreenViewModel: VideoScreenViewModel) {
|
||||||
|
val tabIndex by videoScreenViewModel.tabIndex;
|
||||||
Card(
|
Card(
|
||||||
shape = RoundedCornerShape(6.dp),
|
shape = RoundedCornerShape(6.dp),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.wrapContentHeight(),
|
.wrapContentHeight(),
|
||||||
onClick = {
|
onClick = {
|
||||||
Global.sameClassVideos = videoScreenViewModel.videos
|
Global.sameClassVideos = videoScreenViewModel.classesMap[videoScreenViewModel.classes[tabIndex]] ?: mutableStateListOf()
|
||||||
val route = "video_player_route/${ "${video.klass}/${video.id}".toHex() }"
|
val route = "video_player_route/${ "${video.klass}/${video.id}".toHex() }"
|
||||||
navController.navigate(route)
|
navController.navigate(route)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.acitelight.aether.viewModel
|
package com.acitelight.aether.viewModel
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import androidx.annotation.OptIn
|
import androidx.annotation.OptIn
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.State
|
import androidx.compose.runtime.State
|
||||||
@@ -41,12 +40,7 @@ class VideoPlayerViewModel() : ViewModel()
|
|||||||
var playProcess by mutableFloatStateOf(0.0f)
|
var playProcess by mutableFloatStateOf(0.0f)
|
||||||
var planeVisibility by mutableStateOf(true)
|
var planeVisibility by mutableStateOf(true)
|
||||||
var isLongPressing by mutableStateOf(false)
|
var isLongPressing by mutableStateOf(false)
|
||||||
|
var dragging by mutableStateOf(false)
|
||||||
// -1 : Not dragging
|
|
||||||
// 0 : Seek
|
|
||||||
// 1 : Volume
|
|
||||||
// 2 : Brightness
|
|
||||||
var draggingPurpose by mutableIntStateOf(-1)
|
|
||||||
|
|
||||||
var thumbUp by mutableIntStateOf(0)
|
var thumbUp by mutableIntStateOf(0)
|
||||||
var thumbDown by mutableIntStateOf(0)
|
var thumbDown by mutableIntStateOf(0)
|
||||||
@@ -59,7 +53,6 @@ class VideoPlayerViewModel() : ViewModel()
|
|||||||
|
|
||||||
val dataSourceFactory = OkHttpDataSource.Factory(createOkHttp())
|
val dataSourceFactory = OkHttpDataSource.Factory(createOkHttp())
|
||||||
var imageLoader: ImageLoader? = null;
|
var imageLoader: ImageLoader? = null;
|
||||||
var brit by mutableFloatStateOf(0.5f)
|
|
||||||
|
|
||||||
@OptIn(UnstableApi::class)
|
@OptIn(UnstableApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
@@ -3,51 +3,35 @@ package com.acitelight.aether.viewModel
|
|||||||
import android.app.Application
|
import android.app.Application
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.State
|
import androidx.compose.runtime.State
|
||||||
import androidx.compose.runtime.collectAsState
|
|
||||||
import androidx.compose.runtime.getValue
|
|
||||||
import androidx.compose.runtime.mutableIntStateOf
|
import androidx.compose.runtime.mutableIntStateOf
|
||||||
import androidx.compose.runtime.mutableStateListOf
|
import androidx.compose.runtime.mutableStateListOf
|
||||||
|
import androidx.compose.runtime.mutableStateMapOf
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.snapshots.SnapshotStateList
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.datastore.preferences.core.stringPreferencesKey
|
import androidx.datastore.preferences.core.stringPreferencesKey
|
||||||
import androidx.lifecycle.AndroidViewModel
|
import androidx.lifecycle.AndroidViewModel
|
||||||
import androidx.lifecycle.ViewModel
|
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import coil3.ImageLoader
|
import coil3.ImageLoader
|
||||||
import coil3.network.okhttp.OkHttpNetworkFetcherFactory
|
import coil3.network.okhttp.OkHttpNetworkFetcherFactory
|
||||||
import com.acitelight.aether.Global
|
|
||||||
import com.acitelight.aether.dataStore
|
import com.acitelight.aether.dataStore
|
||||||
import com.acitelight.aether.model.Video
|
import com.acitelight.aether.model.Video
|
||||||
import com.acitelight.aether.service.ApiClient
|
|
||||||
import com.acitelight.aether.service.ApiClient.createOkHttp
|
import com.acitelight.aether.service.ApiClient.createOkHttp
|
||||||
import com.acitelight.aether.service.AuthManager
|
|
||||||
import com.acitelight.aether.service.MediaManager
|
import com.acitelight.aether.service.MediaManager
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class VideoScreenViewModel(application: Application) : AndroidViewModel(application)
|
class VideoScreenViewModel(application: Application) : AndroidViewModel(application)
|
||||||
{
|
{
|
||||||
private val dataStore = application.dataStore
|
|
||||||
private val USER_NAME_KEY = stringPreferencesKey("user_name")
|
|
||||||
private val PRIVATE_KEY = stringPreferencesKey("private_key")
|
|
||||||
|
|
||||||
val userNameFlow: Flow<String> = dataStore.data.map { preferences ->
|
|
||||||
preferences[USER_NAME_KEY] ?: ""
|
|
||||||
}
|
|
||||||
|
|
||||||
val privateKeyFlow: Flow<String> = dataStore.data.map { preferences ->
|
|
||||||
preferences[PRIVATE_KEY] ?: ""
|
|
||||||
}
|
|
||||||
|
|
||||||
private val _tabIndex = mutableIntStateOf(0)
|
private val _tabIndex = mutableIntStateOf(0)
|
||||||
val tabIndex: State<Int> = _tabIndex
|
val tabIndex: State<Int> = _tabIndex
|
||||||
|
// val videos = mutableStateListOf<Video>()
|
||||||
|
// private val _klasses = MutableStateFlow<List<String>>(emptyList())
|
||||||
|
var classes = mutableStateListOf<String>()
|
||||||
|
val classesMap = mutableStateMapOf<String, SnapshotStateList<Video>>()
|
||||||
|
|
||||||
val videos = mutableStateListOf<Video>()
|
|
||||||
private val _klasses = MutableStateFlow<List<String>>(emptyList())
|
|
||||||
val klasses: StateFlow<List<String>> = _klasses;
|
|
||||||
var imageLoader: ImageLoader? = null;
|
var imageLoader: ImageLoader? = null;
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -62,10 +46,14 @@ class VideoScreenViewModel(application: Application) : AndroidViewModel(applicat
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun init() {
|
suspend fun init() {
|
||||||
_klasses.value = MediaManager.listVideoKlasses()
|
classes.addAll(MediaManager.listVideoKlasses())
|
||||||
|
for(it in classes)
|
||||||
|
{
|
||||||
|
classesMap[it] = mutableStateListOf<Video>()
|
||||||
|
}
|
||||||
|
|
||||||
MediaManager.listVideos(_klasses.value.first()){
|
MediaManager.listVideos(classes[0]){
|
||||||
v -> if(0 == tabIndex.value && !videos.contains(v)) videos.add(videos.size, v)
|
v -> classesMap[classes[0]]?.add(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,10 +63,9 @@ class VideoScreenViewModel(application: Application) : AndroidViewModel(applicat
|
|||||||
{
|
{
|
||||||
_tabIndex.intValue = index;
|
_tabIndex.intValue = index;
|
||||||
|
|
||||||
videos.clear()
|
MediaManager.listVideos(classes[index])
|
||||||
MediaManager.listVideos(_klasses.value[index])
|
|
||||||
{
|
{
|
||||||
v -> if(index == tabIndex.value) videos.add(videos.size, v)
|
v -> classesMap[classes[index]]?.add(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user