INNER CODE UNIT · Swift
playCustomSound
cometchat/cometchat-uikit-flutter · packages/cometchat_uikit/ios/Classes/SwiftCometchatChatUikitPlugin.swift:429
private func playCustomSound(args: [String: Any], result: @escaping FlutterResult) {
guard
let assetPath = args["assetAudioPath"] as? String,
let key = globalRegistrar?.lookupKey(forAsset: assetPath),
let path = Bundle.main.path(forResource: key, ofType: nil)
else {
result(false)
return
}
do {
audioPlayer = try AVAudioPlayer(contentsOf: URL(fileURLWithPath: path))
audioPlayer?.play()
result(true)
} catch {
result(false)
}
}