Alexis
08/05/2024, 4:03 PMFrançois
08/05/2024, 4:05 PMFrançois
08/05/2024, 4:05 PMFrançois
08/05/2024, 4:08 PMAlexis
08/05/2024, 4:13 PMFrançois
08/05/2024, 4:14 PMAlexis
08/05/2024, 4:19 PM@Composable
internal fun MapKitView(
modifier: Modifier,
placeName: String,
coordinate: MapCoordinates
) {
val factory = LocalNativeViewFactory.current
UIKitViewController(
modifier = modifier,
factory = { factory.createMapView(placeName, coordinate) },
)
}
François
08/05/2024, 4:26 PMAlexis
08/05/2024, 4:38 PMactual class SoundController actual constructor(
private val preferenceRepository: PreferenceRepository
) : KoinComponent {
private var playerButtonFeedback = createPlayer("sound_menu_button", "wav")
private var playerWarningFeedback = createPlayer("sound_menu_denied", "wav")
private var isSoundOn = true
private val scope = CoroutineScope(<http://Dispatchers.IO|Dispatchers.IO>)
private val playerScope = CoroutineScope(Dispatchers.Main)
private var prefsJob: Job? = null
init {
prefsJob?.cancel()
prefsJob = scope.launch {
preferenceRepository.preferences.collect { isSoundOn = it.sound }
}
}
actual fun playSound(sound: AppSound) {
println("Play sound: ${sound.name}")
playerScope.launch {
if (isSoundOn) when (sound) {
AppSound.ButtonFeedback -> if (playerButtonFeedback.status == 0L) playerButtonFeedback.play()
AppSound.DeniedFeedback -> if (playerWarningFeedback.status == 0L) playerWarningFeedback.play()
}
}
}
private fun createPlayer(resourceName: String, type: String): AVPlayer {
val path = NSBundle.mainBundle.pathForResource(resourceName, type)
val url = NSURL.fileURLWithPath(path!!)
return AVPlayer.playerWithURL(url)
}
}
But I can't hear any sound, the resources seem to be located correctly.François
08/05/2024, 4:55 PMAlexis
08/05/2024, 5:00 PMFrançois
08/05/2024, 5:02 PM