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()
|
||||
.also {
|
||||
it.addListener(MusicPlayerListener(it, _state))
|
||||
it.prepare()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -85,7 +84,10 @@ class MusicService
|
|||
}
|
||||
}
|
||||
}
|
||||
onMain { player.play() }
|
||||
onMain {
|
||||
player.prepare()
|
||||
player.play()
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun stop() {
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ fun NowPlayingButtons(
|
|||
controllerViewState: ControllerViewState,
|
||||
initialFocusRequester: FocusRequester,
|
||||
onClickMore: () -> Unit,
|
||||
onClickStop: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val playPauseState = rememberPlayPauseButtonState(player)
|
||||
|
|
@ -87,6 +88,15 @@ fun NowPlayingButtons(
|
|||
onControllerInteraction = onControllerInteraction,
|
||||
modifier = Modifier,
|
||||
)
|
||||
PlaybackButton(
|
||||
iconRes = R.drawable.baseline_stop_24,
|
||||
onClick = {
|
||||
onClickStop.invoke()
|
||||
},
|
||||
enabled = true,
|
||||
onControllerInteraction = onControllerInteraction,
|
||||
modifier = Modifier,
|
||||
)
|
||||
}
|
||||
PlaybackButtons(
|
||||
player = player,
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ fun NowPlayingOverlay(
|
|||
onClickMore: () -> Unit,
|
||||
onMoveQueue: (Int, MoveDirection) -> Unit,
|
||||
onClickMoreItem: (Int, AudioItem) -> Unit,
|
||||
onClickStop: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val scope = rememberCoroutineScope()
|
||||
|
|
@ -131,6 +132,7 @@ fun NowPlayingOverlay(
|
|||
controllerViewState = controllerViewState,
|
||||
initialFocusRequester = focusRequester,
|
||||
onClickMore = onClickMore,
|
||||
onClickStop = onClickStop,
|
||||
modifier =
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
|
|
|
|||
|
|
@ -231,6 +231,7 @@ fun NowPlayingPage(
|
|||
onClickSong = { index, _ -> viewModel.play(index) },
|
||||
onClickMoreItem = { index, song -> showContextForItem.invoke(false, index, song) },
|
||||
onLongClickSong = { index, song -> showContextForItem.invoke(true, index, song) },
|
||||
onClickStop = { viewModel.stop() },
|
||||
modifier =
|
||||
Modifier
|
||||
.background(AppColors.TransparentBlack50)
|
||||
|
|
|
|||
|
|
@ -185,7 +185,9 @@ class NowPlayingViewModel
|
|||
fun removeFromQueue(index: Int) = viewModelScope.launchDefault { musicService.removeFromQueue(index) }
|
||||
|
||||
fun stop() {
|
||||
player.stop()
|
||||
viewModelScope.launchDefault {
|
||||
musicService.stop()
|
||||
navigationManager.goBack()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue