|
1 | 1 | package uk.co.sentinelweb.cuer.net.remote
|
2 | 2 |
|
3 | 3 | import kotlinx.coroutines.withContext
|
| 4 | +import rewriteIdsToSource |
4 | 5 | import uk.co.sentinelweb.cuer.app.orchestrator.OrchestratorContract.Identifier.Locator
|
| 6 | +import uk.co.sentinelweb.cuer.app.orchestrator.OrchestratorContract.Source.* |
5 | 7 | import uk.co.sentinelweb.cuer.core.providers.CoroutineContextProvider
|
6 | 8 | import uk.co.sentinelweb.cuer.core.wrapper.LogWrapper
|
7 | 9 | import uk.co.sentinelweb.cuer.domain.PlayerNodeDomain
|
8 | 10 | import uk.co.sentinelweb.cuer.domain.PlaylistItemDomain
|
9 | 11 | import uk.co.sentinelweb.cuer.net.NetResult
|
10 | 12 | import uk.co.sentinelweb.cuer.net.client.RequestFailureException
|
| 13 | +import uk.co.sentinelweb.cuer.remote.server.LocalRepository |
| 14 | +import uk.co.sentinelweb.cuer.remote.server.locator |
11 | 15 | import uk.co.sentinelweb.cuer.remote.server.player.PlayerSessionContract.PlayerCommandMessage
|
12 | 16 | import uk.co.sentinelweb.cuer.remote.server.player.PlayerSessionContract.PlayerStatusMessage
|
13 | 17 |
|
14 | 18 | internal class RemotePlayerKtorInteractor(
|
15 | 19 | private val service: RemotePlayerService,
|
16 | 20 | private val log: LogWrapper,
|
17 |
| - private val coroutines: CoroutineContextProvider |
| 21 | + private val coroutines: CoroutineContextProvider, |
| 22 | + private val localRepository: LocalRepository, |
18 | 23 | ) : RemotePlayerInteractor {
|
19 | 24 |
|
20 | 25 | init {
|
@@ -65,7 +70,15 @@ internal class RemotePlayerKtorInteractor(
|
65 | 70 | screenIndex: Int
|
66 | 71 | ): NetResult<Boolean> = withContext(coroutines.IO) {
|
67 | 72 | try {
|
68 |
| - service.executeLaunchVideo(locator, item, screenIndex) |
| 73 | + item |
| 74 | + .let { |
| 75 | + it |
| 76 | + .takeIf { it.id?.source == LOCAL || it.id?.source == MEMORY } |
| 77 | + ?.rewriteIdsToSource(LOCAL_NETWORK, localRepository.localNode.locator()) |
| 78 | + ?: it |
| 79 | + } |
| 80 | + .also { service.executeLaunchVideo(locator, it, screenIndex) } |
| 81 | + |
69 | 82 | NetResult.Data(true)
|
70 | 83 | } catch (failure: RequestFailureException) {
|
71 | 84 | log.e("player launch failed", failure)
|
|
0 commit comments