It seem that the sample code is missing the line try? AVAudioSession.sharedInstance().setCategory(.playback) without which the AVPlayer does not play the sound. Changing the code as follows fixes the issue
var player: AVPlayer {
try? AVAudioSession.sharedInstance().setCategory(.playback)
return AVPlayer.sharedDingPlayer
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: