feat: Miniplayer work
This commit is contained in:
parent
9c45c76ec0
commit
595ad702f8
5
TODO.md
5
TODO.md
|
@ -28,7 +28,7 @@ x CI pipeline (gradle?)
|
||||||
- add themes and selection
|
- add themes and selection
|
||||||
- Add NSFW filter
|
- Add NSFW filter
|
||||||
- Translate all strings
|
- Translate all strings
|
||||||
- Swipe player down and up
|
- Swipe miniplayer down and up
|
||||||
- implement preferences using data stores
|
- implement preferences using data stores
|
||||||
|
|
||||||
Issues:
|
Issues:
|
||||||
|
@ -40,4 +40,5 @@ x Refreshing video list causes odd loading order of video items
|
||||||
- playback rotate on click doesn't re-hide buttons
|
- playback rotate on click doesn't re-hide buttons
|
||||||
- Explore list is memory intensive, leak??
|
- Explore list is memory intensive, leak??
|
||||||
- Access Token refresh circular injection problem
|
- Access Token refresh circular injection problem
|
||||||
- app crashes when clicking items in background list while player is visible (minimode)
|
x app crashes when clicking items in background list while player is visible (minimode)
|
||||||
|
- Opening more in player stops player in background
|
|
@ -108,10 +108,11 @@ fun VideoListScreen(
|
||||||
bottomBar = {
|
bottomBar = {
|
||||||
BottomBarComponent(navController)
|
BottomBarComponent(navController)
|
||||||
}
|
}
|
||||||
) {
|
) { contentPadding ->
|
||||||
// Pull to refresh
|
// Pull to refresh
|
||||||
// TODO: fix appbar blank issue
|
// TODO: fix appbar blank issue
|
||||||
SwipeRefresh(
|
SwipeRefresh(
|
||||||
|
modifier = Modifier.padding(contentPadding),
|
||||||
state = rememberSwipeRefreshState(
|
state = rememberSwipeRefreshState(
|
||||||
isRefreshing = (lazyVideoItems.loadState.refresh is LoadState.Loading) || (lazyVideoExploreItems.loadState.refresh is LoadState.Loading)
|
isRefreshing = (lazyVideoItems.loadState.refresh is LoadState.Loading) || (lazyVideoExploreItems.loadState.refresh is LoadState.Loading)
|
||||||
),
|
),
|
||||||
|
|
|
@ -221,6 +221,12 @@ class VideoPlayViewModel @Inject constructor(
|
||||||
_eventFlow.emit(UiEvent.ShowMore)
|
_eventFlow.emit(UiEvent.ShowMore)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
is VideoPlayEvent.MiniPlayerButton -> {
|
||||||
|
Log.v("VPVM", "Video Miniplayer Pressed")
|
||||||
|
viewModelScope.launch {
|
||||||
|
_eventFlow.emit(UiEvent.ShowMiniPlayer)
|
||||||
|
}
|
||||||
|
}
|
||||||
is VideoPlayEvent.PlayVideo -> {
|
is VideoPlayEvent.PlayVideo -> {
|
||||||
// Load new video
|
// Load new video
|
||||||
getVideo(event.video.uuid)
|
getVideo(event.video.uuid)
|
||||||
|
@ -259,5 +265,7 @@ class VideoPlayViewModel @Inject constructor(
|
||||||
object HideDescription : UiEvent()
|
object HideDescription : UiEvent()
|
||||||
object ShowMore : UiEvent()
|
object ShowMore : UiEvent()
|
||||||
object HideMore : UiEvent()
|
object HideMore : UiEvent()
|
||||||
|
object ShowMiniPlayer : UiEvent()
|
||||||
|
object HideMiniPlayer : UiEvent()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -27,7 +27,6 @@ import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.constraintlayout.compose.*
|
import androidx.constraintlayout.compose.*
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
import androidx.hilt.navigation.compose.hiltViewModel
|
||||||
import androidx.navigation.NavController
|
|
||||||
import androidx.paging.compose.LazyPagingItems
|
import androidx.paging.compose.LazyPagingItems
|
||||||
import androidx.paging.compose.collectAsLazyPagingItems
|
import androidx.paging.compose.collectAsLazyPagingItems
|
||||||
import androidx.paging.compose.itemsIndexed
|
import androidx.paging.compose.itemsIndexed
|
||||||
|
@ -53,10 +52,11 @@ fun VideoPlayScreen(
|
||||||
val state = videoPlayViewModel.state.value
|
val state = videoPlayViewModel.state.value
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
||||||
|
var miniPlayerVisible by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
var descriptionVisible by remember { mutableStateOf(false) }
|
var descriptionVisible by remember { mutableStateOf(false) }
|
||||||
var moreVisible by remember { mutableStateOf(false) }
|
var moreVisible by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
// Show toasts
|
|
||||||
LaunchedEffect(key1 = true) {
|
LaunchedEffect(key1 = true) {
|
||||||
videoPlayViewModel.eventFlow.collectLatest { event ->
|
videoPlayViewModel.eventFlow.collectLatest { event ->
|
||||||
when(event) {
|
when(event) {
|
||||||
|
@ -79,6 +79,12 @@ fun VideoPlayScreen(
|
||||||
is VideoPlayViewModel.UiEvent.HideMore -> {
|
is VideoPlayViewModel.UiEvent.HideMore -> {
|
||||||
moreVisible = false
|
moreVisible = false
|
||||||
}
|
}
|
||||||
|
is VideoPlayViewModel.UiEvent.ShowMiniPlayer -> {
|
||||||
|
miniPlayerVisible = true
|
||||||
|
}
|
||||||
|
is VideoPlayViewModel.UiEvent.HideMiniPlayer -> {
|
||||||
|
miniPlayerVisible = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,9 +101,9 @@ fun VideoPlayScreen(
|
||||||
|
|
||||||
val configuration = LocalConfiguration.current
|
val configuration = LocalConfiguration.current
|
||||||
|
|
||||||
var animateToEnd by remember { mutableStateOf(false) }
|
|
||||||
val progress by animateFloatAsState(
|
val progress by animateFloatAsState(
|
||||||
targetValue = if (animateToEnd) 1f else 0f,
|
targetValue = if (miniPlayerVisible) 1f else 0f,
|
||||||
animationSpec = tween(250)
|
animationSpec = tween(250)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -239,8 +245,10 @@ fun VideoPlayScreen(
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.layoutId("background", "box")
|
.layoutId("background", "box")
|
||||||
.background(Color.Blue)
|
.background(Color.White)
|
||||||
.clickable(onClick = { animateToEnd = !animateToEnd })
|
.clickable(onClick = {
|
||||||
|
miniPlayerVisible = false
|
||||||
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
VideoScreen(exoPlayerHolder, video,
|
VideoScreen(exoPlayerHolder, video,
|
||||||
|
@ -252,7 +260,9 @@ fun VideoPlayScreen(
|
||||||
Text(
|
Text(
|
||||||
text = "MotionLayout in Compose",
|
text = "MotionLayout in Compose",
|
||||||
modifier = Modifier.layoutId("title")
|
modifier = Modifier.layoutId("title")
|
||||||
.clickable(onClick = { animateToEnd = !animateToEnd }),
|
.clickable(onClick = {
|
||||||
|
miniPlayerVisible = false
|
||||||
|
}),
|
||||||
color = MaterialTheme.colors.onBackground,
|
color = MaterialTheme.colors.onBackground,
|
||||||
fontSize = motionProperties("title").value.fontSize("textSize")
|
fontSize = motionProperties("title").value.fontSize("textSize")
|
||||||
)
|
)
|
||||||
|
@ -379,7 +389,12 @@ fun VideoPlayScreen(
|
||||||
}
|
}
|
||||||
BackHandler(enabled = true) {
|
BackHandler(enabled = true) {
|
||||||
Log.v("back", "back pressed")
|
Log.v("back", "back pressed")
|
||||||
|
if (!miniPlayerVisible) {
|
||||||
|
miniPlayerVisible = true;
|
||||||
|
} else {
|
||||||
videoPlayViewModel.playerVisible.value = false
|
videoPlayViewModel.playerVisible.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,12 @@ fun VideoScreen(
|
||||||
|
|
||||||
Log.v("VideoScreen", "videoMoreButton")
|
Log.v("VideoScreen", "videoMoreButton")
|
||||||
|
|
||||||
|
// Video MiniPlayer Button
|
||||||
|
val videoMiniplayerButton = playerView.findViewById<ImageButton>(R.id.exo_miniplayer)
|
||||||
|
videoMiniplayerButton.setOnClickListener {
|
||||||
|
viewModel.onEvent(VideoPlayEvent.MiniPlayerButton)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: does not update on orientation gesture
|
// TODO: does not update on orientation gesture
|
||||||
val enterFullscreenIcon = playerView.findViewById<ImageButton>(R.id.exo_fullscreen_enable)
|
val enterFullscreenIcon = playerView.findViewById<ImageButton>(R.id.exo_fullscreen_enable)
|
||||||
|
|
|
@ -13,6 +13,7 @@ sealed class VideoPlayEvent {
|
||||||
data class OpenDescription(val video: Video): VideoPlayEvent()
|
data class OpenDescription(val video: Video): VideoPlayEvent()
|
||||||
object CloseDescription: VideoPlayEvent()
|
object CloseDescription: VideoPlayEvent()
|
||||||
object MoreButton: VideoPlayEvent()
|
object MoreButton: VideoPlayEvent()
|
||||||
|
object MiniPlayerButton: VideoPlayEvent()
|
||||||
data class PlayVideo(val video: Video): VideoPlayEvent()
|
data class PlayVideo(val video: Video): VideoPlayEvent()
|
||||||
object CloseVideo: VideoPlayEvent()
|
object CloseVideo: VideoPlayEvent()
|
||||||
}
|
}
|
|
@ -46,6 +46,10 @@
|
||||||
<ImageButton android:id="@+id/exo_more"
|
<ImageButton android:id="@+id/exo_more"
|
||||||
style="@style/ExoStyledControls.Button.Bottom.Settings"/>
|
style="@style/ExoStyledControls.Button.Bottom.Settings"/>
|
||||||
|
|
||||||
|
<ImageButton android:id="@+id/exo_miniplayer"
|
||||||
|
style="@style/ExoStyledControls.Button.Bottom.OverflowHide"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/exo_fullscreen_button"
|
android:id="@+id/exo_fullscreen_button"
|
||||||
|
|
Loading…
Reference in New Issue