fix background playback

master
Bill 2 years ago
parent 740f63d0d6
commit a6266ee3db

@ -188,7 +188,7 @@ struct ContentView: View {
print(self.player.error!) print(self.player.error!)
} }
else { else {
//self.player.play() self.player.play()
} }
} }
init() { init() {
@ -202,7 +202,7 @@ struct ContentView: View {
do { do {
let session = AVAudioSession.sharedInstance() let session = AVAudioSession.sharedInstance()
try session.setCategory(AVAudioSession.Category.playback) try session.setCategory(AVAudioSession.Category.playback, mode: .default, policy: .longFormAudio, options: .duckOthers)
} catch { } catch {
print(error) print(error)
} }

@ -69,6 +69,7 @@ struct PlaybackView: View {
parent!.player.pause() parent!.player.pause()
self.playing = false self.playing = false
} else { } else {
parent!.player.audiovisualBackgroundPlaybackPolicy = .continuesIfPossible
parent!.player.play() parent!.player.play()
self.playing = true self.playing = true
} }

@ -36,5 +36,21 @@
landmarkType = "9"> landmarkType = "9">
</BreakpointContent> </BreakpointContent>
</BreakpointProxy> </BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "26EC7C75-1CAF-4528-A913-46A2A74EC392"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "MusicPlayer Watch App/ContentView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "277"
endingLineNumber = "277"
landmarkName = "try_download(u:r:e:)"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints> </Breakpoints>
</Bucket> </Bucket>

Loading…
Cancel
Save