I'm trying to see if I can get audio playback working on iOS with
AVAudioPlayer
, and no matter what I do, just
instantiating it gives me a null pointer exception. Based on some other threads here in this Slack, the latest thing I'm trying is:
lateinit var player: AVAudioPlayer
memScoped {
val errorPtr: ObjCObjectVar<NSError?> = alloc<ObjCObjectVar<NSError?>>()
player = AVAudioPlayer(mp3Url!!, errorPtr.ptr)
//println(errorPtr.ptr) //Will be null if the call succeeds.
}
My theory is that I'm not passing the right thing for the second argument of the constructor; it's the weird objc error pointer thingy. That said, the argument says it is nullable, so it wold seem passing null should work there. I tried that but have the same NPE.
Has anyone else gotten
AVAudioPlayer
to work? Gotten the objs error pointers to work?