Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Audio Background Play #84

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DarockBili Watch App/Video/AudioPlayerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ struct AudioPlayerView: View {
.onAppear {
// Background Session
do {
try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default, options: [.mixWithOthers])
try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default, policy: .longFormAudio, options: [.duckOthers])
try AVAudioSession.sharedInstance().setActive(true)
} catch {
print(error)
Expand Down
3 changes: 1 addition & 2 deletions DarockBili Watch App/Video/VideoDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,8 @@ struct VideoDetailView: View {
DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/player/playurl?platform=html5&bvid=\(videoDetails["BV"]!)&cid=\(cid)", headers: headers) { respJson, isSuccess in
if !CheckBApiError(from: respJson) { return }
VideoDetailView.willPlayVideoLink = respJson["data"]["durl"][0]["url"].string!.replacingOccurrences(of: "\\u0026", with: "&")
//debugPrint(response)
VideoDetailView.willPlayVideoBV = videoDetails["BV"]!
isVideoPlayerPresented = true
isNowPlayingPresented = true
isLoading = false
}
}
Expand Down