File tree 3 files changed +22
-13
lines changed
commonMain/kotlin/com/toasterofbread/spmp
ui/layout/apppage/settingspage/category
desktopMain/kotlin/com/toasterofbread/spmp/platform/playerservice
3 files changed +22
-13
lines changed Original file line number Diff line number Diff line change @@ -222,10 +222,18 @@ class PlayerState(
222
222
}
223
223
}
224
224
225
- private fun getServiceCompanion (): PlayerServiceCompanion =
226
- if (! PlatformInternalPlayerService .isServiceAttached(context) && (! PlatformInternalPlayerService .isAvailable(context, launch_arguments) || settings.platform.ENABLE_EXTERNAL_SERVER_MODE .get()))
227
- PlatformExternalPlayerService
228
- else PlatformInternalPlayerService
225
+ private fun getServiceCompanion (): PlayerServiceCompanion {
226
+ if (! PlatformInternalPlayerService .isAvailable(context, launch_arguments)) {
227
+ return PlatformExternalPlayerService
228
+ }
229
+ if (PlatformInternalPlayerService .isServiceAttached(context)) {
230
+ return PlatformInternalPlayerService
231
+ }
232
+ if (settings.platform.ENABLE_EXTERNAL_SERVER_MODE .get()) {
233
+ return PlatformExternalPlayerService
234
+ }
235
+ return PlatformInternalPlayerService
236
+ }
229
237
230
238
fun onStart () {
231
239
SpMp .addLowMemoryListener(low_memory_listener)
Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ fun getServerGroupItems(context: AppContext): List<SettingsItem> {
95
95
getSubtitleOverride = {
96
96
getLocalServerUnavailabilityReason()
97
97
}
98
- ),
98
+ ). takeIf { ! Platform . DESKTOP .isCurrent() } ,
99
99
100
100
ToggleSettingsItem (context.settings.platform.EXTERNAL_SERVER_MODE_UI_ONLY ).takeIf { PlatformExternalPlayerService .playsAudio() },
101
101
Original file line number Diff line number Diff line change @@ -3,17 +3,18 @@ package com.toasterofbread.spmp.platform.playerservice
3
3
import ProgramArguments
4
4
import com.toasterofbread.spmp.platform.AppContext
5
5
import com.toasterofbread.spmp.platform.PlatformBinder
6
- import dev.toastbits.composekit.platform.PlatformFile
7
6
import dev.toastbits.spms.server.SpMs
8
7
9
8
private class PlayerServiceBinder (val service : PlatformInternalPlayerService ): PlatformBinder()
10
9
11
10
actual class PlatformInternalPlayerService : ExternalPlayerService (plays_audio = false ) {
12
- private fun launchLocalServer () {
13
- LocalServer .startLocalServer(
14
- context,
15
- context.settings.platform.SERVER_PORT .get()
16
- )
11
+ private fun autoLaunchLocalServer () {
12
+ if (context.settings.platform.SERVER_LOCAL_START_AUTOMATICALLY .get()) {
13
+ LocalServer .startLocalServer(
14
+ context,
15
+ context.settings.platform.SERVER_PORT .get()
16
+ )
17
+ }
17
18
}
18
19
19
20
actual companion object : PlayerServiceCompanion {
@@ -36,12 +37,12 @@ actual class PlatformInternalPlayerService: ExternalPlayerService(plays_audio =
36
37
if (instance != null )
37
38
instance.also {
38
39
it.setContext(context)
39
- it.launchLocalServer ()
40
+ it.autoLaunchLocalServer ()
40
41
}
41
42
else
42
43
PlatformInternalPlayerService ().also {
43
44
it.setContext(context)
44
- it.launchLocalServer ()
45
+ it.autoLaunchLocalServer ()
45
46
it.onCreate()
46
47
}
47
48
onConnected(service)
You can’t perform that action at this time.
0 commit comments