mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 15:50:16 +02:00
Add stop button
This commit is contained in:
parent
3359c8ac32
commit
d8a58a6d96
5 changed files with 21 additions and 4 deletions
|
|
@ -68,7 +68,6 @@ class MusicService
|
||||||
).build()
|
).build()
|
||||||
.also {
|
.also {
|
||||||
it.addListener(MusicPlayerListener(it, _state))
|
it.addListener(MusicPlayerListener(it, _state))
|
||||||
it.prepare()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,7 +84,10 @@ class MusicService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onMain { player.play() }
|
onMain {
|
||||||
|
player.prepare()
|
||||||
|
player.play()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun stop() {
|
suspend fun stop() {
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ fun NowPlayingButtons(
|
||||||
controllerViewState: ControllerViewState,
|
controllerViewState: ControllerViewState,
|
||||||
initialFocusRequester: FocusRequester,
|
initialFocusRequester: FocusRequester,
|
||||||
onClickMore: () -> Unit,
|
onClickMore: () -> Unit,
|
||||||
|
onClickStop: () -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
val playPauseState = rememberPlayPauseButtonState(player)
|
val playPauseState = rememberPlayPauseButtonState(player)
|
||||||
|
|
@ -87,6 +88,15 @@ fun NowPlayingButtons(
|
||||||
onControllerInteraction = onControllerInteraction,
|
onControllerInteraction = onControllerInteraction,
|
||||||
modifier = Modifier,
|
modifier = Modifier,
|
||||||
)
|
)
|
||||||
|
PlaybackButton(
|
||||||
|
iconRes = R.drawable.baseline_stop_24,
|
||||||
|
onClick = {
|
||||||
|
onClickStop.invoke()
|
||||||
|
},
|
||||||
|
enabled = true,
|
||||||
|
onControllerInteraction = onControllerInteraction,
|
||||||
|
modifier = Modifier,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
PlaybackButtons(
|
PlaybackButtons(
|
||||||
player = player,
|
player = player,
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ fun NowPlayingOverlay(
|
||||||
onClickMore: () -> Unit,
|
onClickMore: () -> Unit,
|
||||||
onMoveQueue: (Int, MoveDirection) -> Unit,
|
onMoveQueue: (Int, MoveDirection) -> Unit,
|
||||||
onClickMoreItem: (Int, AudioItem) -> Unit,
|
onClickMoreItem: (Int, AudioItem) -> Unit,
|
||||||
|
onClickStop: () -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
|
@ -131,6 +132,7 @@ fun NowPlayingOverlay(
|
||||||
controllerViewState = controllerViewState,
|
controllerViewState = controllerViewState,
|
||||||
initialFocusRequester = focusRequester,
|
initialFocusRequester = focusRequester,
|
||||||
onClickMore = onClickMore,
|
onClickMore = onClickMore,
|
||||||
|
onClickStop = onClickStop,
|
||||||
modifier =
|
modifier =
|
||||||
Modifier
|
Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
|
|
||||||
|
|
@ -231,6 +231,7 @@ fun NowPlayingPage(
|
||||||
onClickSong = { index, _ -> viewModel.play(index) },
|
onClickSong = { index, _ -> viewModel.play(index) },
|
||||||
onClickMoreItem = { index, song -> showContextForItem.invoke(false, index, song) },
|
onClickMoreItem = { index, song -> showContextForItem.invoke(false, index, song) },
|
||||||
onLongClickSong = { index, song -> showContextForItem.invoke(true, index, song) },
|
onLongClickSong = { index, song -> showContextForItem.invoke(true, index, song) },
|
||||||
|
onClickStop = { viewModel.stop() },
|
||||||
modifier =
|
modifier =
|
||||||
Modifier
|
Modifier
|
||||||
.background(AppColors.TransparentBlack50)
|
.background(AppColors.TransparentBlack50)
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,9 @@ class NowPlayingViewModel
|
||||||
fun removeFromQueue(index: Int) = viewModelScope.launchDefault { musicService.removeFromQueue(index) }
|
fun removeFromQueue(index: Int) = viewModelScope.launchDefault { musicService.removeFromQueue(index) }
|
||||||
|
|
||||||
fun stop() {
|
fun stop() {
|
||||||
player.stop()
|
viewModelScope.launchDefault {
|
||||||
|
musicService.stop()
|
||||||
navigationManager.goBack()
|
navigationManager.goBack()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue