ExternalPlayer.ios.kt
composeApp/src/iosMain/kotlin/eu/friedcutlet/yokan/services/media/player/ExternalPlayer.ios.kt
1package eu.friedcutlet.yokan.services.media.player23import eu.friedcutlet.yokan.services.system.openSystemBrowser4import io.ktor.http.encodeURLParameter56/** URL-scheme players; each scheme is listed in Info.plist `LSApplicationQueriesSchemes`. */7private val IosPlayers = listOf(8 ExternalPlayerChoice("vlc", "VLC") to { url: String -> "vlc-x-callback://x-callback-url/stream?url=${url.encodeURLParameter()}" },9 ExternalPlayerChoice("infuse", "Infuse") to { url: String -> "infuse://x-callback-url/play?url=${url.encodeURLParameter()}" },10 ExternalPlayerChoice("outplayer", "Outplayer") to { url: String -> "outplayer://$url" },11)1213actual fun externalPlayerChoices(): List<ExternalPlayerChoice> =14 IosPlayers.map { it.first } + ExternalPlayerChoice("system", "System default")1516actual fun launchExternalPlayer(url: String, headers: Map<String, String>, playerId: String): Boolean {17 // iOS won't honor per-request HTTP headers via openURL; the proxy URL18 // already has them injected, so a blank id hands it to the default19 // handler — VLC / Infuse / etc. will pick it up if installed.20 val player = IosPlayers.firstOrNull { it.first.id == playerId } ?: return openSystemBrowser(url)21 return openSystemBrowser(player.second(url))22}23