fix background playback
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ struct PlaybackView: View {
|
||||
parent!.player.pause()
|
||||
self.playing = false
|
||||
} else {
|
||||
parent!.player.audiovisualBackgroundPlaybackPolicy = .continuesIfPossible
|
||||
parent!.player.play()
|
||||
self.playing = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user