fix background playback

This commit is contained in:
2023-03-23 02:26:26 +08:00
parent 740f63d0d6
commit a6266ee3db
3 changed files with 19 additions and 2 deletions
+2 -2
View File
@@ -188,7 +188,7 @@ struct ContentView: View {
print(self.player.error!)
}
else {
//self.player.play()
self.player.play()
}
}
init() {
@@ -202,7 +202,7 @@ struct ContentView: View {
do {
let session = AVAudioSession.sharedInstance()
try session.setCategory(AVAudioSession.Category.playback)
try session.setCategory(AVAudioSession.Category.playback, mode: .default, policy: .longFormAudio, options: .duckOthers)
} catch {
print(error)
}
+1
View File
@@ -69,6 +69,7 @@ struct PlaybackView: View {
parent!.player.pause()
self.playing = false
} else {
parent!.player.audiovisualBackgroundPlaybackPolicy = .continuesIfPossible
parent!.player.play()
self.playing = true
}