Hi everyone, I m new here , not sure if this is th...
# multiplatform
p
Hi everyone, I m new here , not sure if this is the right place to ask but since everyone is asking here I m using compose multiplatform targets - ios,android What I m trying to do I want to *record audio(*voice notes) and play audio and then store them as BLOB in sqldelight for sometime after that I will upload it to server I m facing issue trying to implement the recording audio part where I will get audio data back as *ByteArray or NSData*(which I will convert to ByteArray), I m no expert and I have been trying to use gpt4 to get help with this but some of the kotlin/native api’s are just not recognised , so I thought to implement the code (recording audio)in swift and call that from kotlin , but I m facing issues with that too, I tried to use the swiftKlib plugin, but that is giving me this error could not build objective C module AVFoundation Any help would be much appreciated, thanks
a
I have audio recording feature in my KMM application, that is how I implemented recording for iOS - https://gist.github.com/yandroidUA/a2ecc2e373de2d77c487732f31925c45 Actually, it just records it into file that I've provided through
NSUrl
and then I read
NSData
from that file and convert it to
ByteArray
- https://gist.github.com/yandroidUA/ed1e67c90182e6ae83a8408de413c55c P.S. And that's the Player for iOS - https://gist.github.com/yandroidUA/2bf3f51329f0b480fa7555bae2e567ce I also have audio uploading feature, but I stick to rather save a file URL in the database and then just upload a bytes from the saved URL when it's a time for syncing with remote server. Also, when fetching the audio, I put it into the file and operate URLs rather than bytes in my "logical" layer of application to play/record the audio.
💯 1
p
Thanks a ton @Andrii Yanechko this will be really helpful for my use case I have another question, right now which is really puzzling to me as why this isn’t working I have defined an interface in ios module in kotlin, and stopRecording() method has return type as NSData and I have written the implementation completely in swift, when I try to run it says type Mismatch but when I change the type to String in both Kotlin interface and swift implementation and pass simple string it works here are two files showing some code snippets https://gist.github.com/Vaibhav-214/ae243679a86cba21a8705f8d4fafbe46