mirror of
https://github.com/sschueller/peertube-android
synced 2025-02-16 11:31:35 +01:00
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 NSFW filter
|
||||
- Translate all strings
|
||||
- Swipe player down and up
|
||||
- Swipe miniplayer down and up
|
||||
- implement preferences using data stores
|
||||
|
||||
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
|
||||
- Explore list is memory intensive, leak??
|
||||
- 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 = {
|
||||
BottomBarComponent(navController)
|
||||
}
|
||||
) {
|
||||
// Pull to refresh
|
||||
) { contentPadding ->
|
||||
// Pull to refresh
|
||||
// TODO: fix appbar blank issue
|
||||
SwipeRefresh(
|
||||
modifier = Modifier.padding(contentPadding),
|
||||
state = rememberSwipeRefreshState(
|
||||
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)
|
||||
}
|
||||
}
|
||||
is VideoPlayEvent.MiniPlayerButton -> {
|
||||
Log.v("VPVM", "Video Miniplayer Pressed")
|
||||
viewModelScope.launch {
|
||||
_eventFlow.emit(UiEvent.ShowMiniPlayer)
|
||||
}
|
||||
}
|
||||
is VideoPlayEvent.PlayVideo -> {
|
||||
// Load new video
|
||||
getVideo(event.video.uuid)
|
||||
@ -259,5 +265,7 @@ class VideoPlayViewModel @Inject constructor(
|
||||
object HideDescription : UiEvent()
|
||||
object ShowMore : 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.constraintlayout.compose.*
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.navigation.NavController
|
||||
import androidx.paging.compose.LazyPagingItems
|
||||
import androidx.paging.compose.collectAsLazyPagingItems
|
||||
import androidx.paging.compose.itemsIndexed
|
||||
@ -53,10 +52,11 @@ fun VideoPlayScreen(
|
||||
val state = videoPlayViewModel.state.value
|
||||
val context = LocalContext.current
|
||||
|
||||
var miniPlayerVisible by remember { mutableStateOf(false) }
|
||||
|
||||
var descriptionVisible by remember { mutableStateOf(false) }
|
||||
var moreVisible by remember { mutableStateOf(false) }
|
||||
|
||||
// Show toasts
|
||||
LaunchedEffect(key1 = true) {
|
||||
videoPlayViewModel.eventFlow.collectLatest { event ->
|
||||
when(event) {
|
||||
@ -79,6 +79,12 @@ fun VideoPlayScreen(
|
||||
is VideoPlayViewModel.UiEvent.HideMore -> {
|
||||
moreVisible = false
|
||||
}
|
||||
is VideoPlayViewModel.UiEvent.ShowMiniPlayer -> {
|
||||
miniPlayerVisible = true
|
||||
}
|
||||
is VideoPlayViewModel.UiEvent.HideMiniPlayer -> {
|
||||
miniPlayerVisible = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -95,9 +101,9 @@ fun VideoPlayScreen(
|
||||
|
||||
val configuration = LocalConfiguration.current
|
||||
|
||||
var animateToEnd by remember { mutableStateOf(false) }
|
||||
|
||||
val progress by animateFloatAsState(
|
||||
targetValue = if (animateToEnd) 1f else 0f,
|
||||
targetValue = if (miniPlayerVisible) 1f else 0f,
|
||||
animationSpec = tween(250)
|
||||
)
|
||||
|
||||
@ -239,8 +245,10 @@ fun VideoPlayScreen(
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.layoutId("background", "box")
|
||||
.background(Color.Blue)
|
||||
.clickable(onClick = { animateToEnd = !animateToEnd })
|
||||
.background(Color.White)
|
||||
.clickable(onClick = {
|
||||
miniPlayerVisible = false
|
||||
})
|
||||
)
|
||||
|
||||
VideoScreen(exoPlayerHolder, video,
|
||||
@ -252,7 +260,9 @@ fun VideoPlayScreen(
|
||||
Text(
|
||||
text = "MotionLayout in Compose",
|
||||
modifier = Modifier.layoutId("title")
|
||||
.clickable(onClick = { animateToEnd = !animateToEnd }),
|
||||
.clickable(onClick = {
|
||||
miniPlayerVisible = false
|
||||
}),
|
||||
color = MaterialTheme.colors.onBackground,
|
||||
fontSize = motionProperties("title").value.fontSize("textSize")
|
||||
)
|
||||
@ -379,7 +389,12 @@ fun VideoPlayScreen(
|
||||
}
|
||||
BackHandler(enabled = true) {
|
||||
Log.v("back", "back pressed")
|
||||
videoPlayViewModel.playerVisible.value = false
|
||||
if (!miniPlayerVisible) {
|
||||
miniPlayerVisible = true;
|
||||
} else {
|
||||
videoPlayViewModel.playerVisible.value = false
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,6 +86,12 @@ fun VideoScreen(
|
||||
|
||||
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
|
||||
val enterFullscreenIcon = playerView.findViewById<ImageButton>(R.id.exo_fullscreen_enable)
|
||||
|
@ -13,6 +13,7 @@ sealed class VideoPlayEvent {
|
||||
data class OpenDescription(val video: Video): VideoPlayEvent()
|
||||
object CloseDescription: VideoPlayEvent()
|
||||
object MoreButton: VideoPlayEvent()
|
||||
object MiniPlayerButton: VideoPlayEvent()
|
||||
data class PlayVideo(val video: Video): VideoPlayEvent()
|
||||
object CloseVideo: VideoPlayEvent()
|
||||
}
|
@ -46,6 +46,10 @@
|
||||
<ImageButton android:id="@+id/exo_more"
|
||||
style="@style/ExoStyledControls.Button.Bottom.Settings"/>
|
||||
|
||||
<ImageButton android:id="@+id/exo_miniplayer"
|
||||
style="@style/ExoStyledControls.Button.Bottom.OverflowHide"/>
|
||||
|
||||
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/exo_fullscreen_button"
|
||||
|
Loading…
x
Reference in New Issue
Block a user