markturnip
05/23/2024, 4:46 AMAVPlayer
but more specifically not using interoperability with Swift/Objective-C using expect/actual
Rather has anyone built an interface PlatformMediaPlayer
which then has an implementation on each platform and is injected into the common code via DI (specifically Koin). ?markturnip
05/23/2024, 8:16 AMenum class PlaybackState {
PLAYING, PAUSED, STOPPED
}
interface PlatformMediaPlayer {
fun play()
fun pause()
val isPlaying: Boolean
val playbackState: StateFlow<PlaybackState>
}
fun initKoin(nativeModule: PlatformMediaPlayer) {
// Start Koin
val koinApp = startKoin {
modules(appModule, module {
single { nativeModule }
})
}.koin
}
markturnip
05/23/2024, 8:16 AM@main
struct iOSApp: App {
init() {
HelperKtKt.doInitKoin(
nativeModule: MediaPlayer()
)
}
markturnip
05/23/2024, 8:17 AMCherrio LLC
05/23/2024, 3:53 PMmarkturnip
05/24/2024, 12:30 AMCherrio LLC
05/24/2024, 6:22 AM