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
|
||||
}
|
||||
|
||||
+16
@@ -36,5 +36,21 @@
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</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>
|
||||
</Bucket>
|
||||
|
||||
Reference in New Issue
Block a user