mirror of
https://github.com/twinksoftware/Gearslip.git
synced 2026-11-30 23:30:32 +01:00
Autoplay waits until the music can reach the car, so a song started on connect no longer loses its first seconds to the capture consent
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4e3f8e6657
commit
e823f2fcee
2 files changed
+13
-2
No files matched your search
@@ -26,6 +26,7 @@ import androidx.compose.ui.graphics.vector.ImageVector
|
|||||||
import androidx.compose.ui.res.vectorResource
|
import androidx.compose.ui.res.vectorResource
|
||||||
import android.support.v4.media.session.PlaybackStateCompat
|
import android.support.v4.media.session.PlaybackStateCompat
|
||||||
import app.seb3thehacker.gearslip.R
|
import app.seb3thehacker.gearslip.R
|
||||||
|
import app.seb3thehacker.gearslip.audio.CarAudio
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
@@ -82,9 +83,10 @@ fun CarHome() {
|
|||||||
val navStatus by CarServices.nav.status.collectAsStateWithLifecycle()
|
val navStatus by CarServices.nav.status.collectAsStateWithLifecycle()
|
||||||
val phase by CarServices.media.phase.collectAsStateWithLifecycle()
|
val phase by CarServices.media.phase.collectAsStateWithLifecycle()
|
||||||
val now by CarServices.media.now.collectAsStateWithLifecycle()
|
val now by CarServices.media.now.collectAsStateWithLifecycle()
|
||||||
|
val capture by CarAudio.capture.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
LaunchedEffect(Unit) { CarServices.autostart(frame) }
|
LaunchedEffect(Unit) { CarServices.autostart(frame) }
|
||||||
LaunchedEffect(phase) { if (phase == CarMedia.Phase.READY) CarServices.autoplayIfDue() }
|
LaunchedEffect(phase, capture) { if (phase == CarMedia.Phase.READY) CarServices.autoplayIfDue() }
|
||||||
|
|
||||||
val navigator = LocalCarNavigator.current
|
val navigator = LocalCarNavigator.current
|
||||||
val panel = navigator.sidePanel
|
val panel = navigator.sidePanel
|
||||||
|
|||||||
@@ -195,9 +195,18 @@ object CarServices {
|
|||||||
stillPlaying = null
|
stillPlaying = null
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called once the media app is connected: starts playback if that was asked for. */
|
/**
|
||||||
|
* Called once the media app is connected, and again once the music can reach the car: starts
|
||||||
|
* playback if that was asked for. Not before the capture is on, when the music goes through
|
||||||
|
* Gearslip: a song started while the consent dialog was still up lost its first seconds.
|
||||||
|
*/
|
||||||
fun autoplayIfDue() {
|
fun autoplayIfDue() {
|
||||||
if (!autoplayPending) return
|
if (!autoplayPending) return
|
||||||
|
if (CarSettings.pipesNow && CarAudio.capture.value != CarAudio.Capture.ON) {
|
||||||
|
// Refused: no music for this drive, and none later from a capture the driver starts.
|
||||||
|
if (CarAudio.capture.value == CarAudio.Capture.DENIED) autoplayPending = false
|
||||||
|
return
|
||||||
|
}
|
||||||
autoplayPending = false
|
autoplayPending = false
|
||||||
if (!media.now.value.playing) media.togglePlay()
|
if (!media.now.value.playing) media.togglePlay()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user