I am trying to play a system sound with a MacOS SwiftUI application. What I wish is just to play a system sound when an image appears...
My code (part of it) is the following
import Foundation
import Cocoa
import SwiftUI
import AVFoundation
...
Image("OK Done")
.resizable()
.frame(width: 100, height: 100)
.offset(x: 40, y: 0)
.opacity(OKisVisible ? 1.0 : 0.0)
.onAppear {
/* AudioServicesPlaySystemSound(1108) This works on iOS only */
AudioServicesPlayAlertSound(1108) // This does not work on macOS Ventura 13.2.1
}
...
Any suggestion ? Thanks