mirror of
https://github.com/mastodon/mastodon-ios.git
synced 2025-01-05 13:27:36 +01:00
fix: GIFV may interrupt music playback issue. resolve #283
This commit is contained in:
parent
1606087ad3
commit
344bcb8ba2
@ -113,6 +113,7 @@ final class VideoPlayerViewModel {
|
||||
.sink { [weak self] status in
|
||||
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: %s status: %s", ((#file as NSString).lastPathComponent), #line, #function, sessionName, status.description)
|
||||
guard let self = self else { return }
|
||||
|
||||
// only update audio session for video
|
||||
guard self.videoKind == .video else { return }
|
||||
switch status {
|
||||
@ -122,7 +123,7 @@ final class VideoPlayerViewModel {
|
||||
try? AVAudioSession.sharedInstance().setCategory(.playback)
|
||||
try? AVAudioSession.sharedInstance().setActive(true)
|
||||
case .paused, .stopped, .failed:
|
||||
try? AVAudioSession.sharedInstance().setCategory(.soloAmbient) // reset to default
|
||||
try? AVAudioSession.sharedInstance().setCategory(.ambient) // set to ambient to allow mixed (needed for GIFV)
|
||||
try? AVAudioSession.sharedInstance().setActive(false, options: .notifyOthersOnDeactivation)
|
||||
}
|
||||
}
|
||||
@ -149,14 +150,6 @@ extension VideoPlayerViewModel {
|
||||
}
|
||||
|
||||
func play() {
|
||||
switch videoKind {
|
||||
case .gif:
|
||||
break
|
||||
case .video:
|
||||
break
|
||||
// try? AVAudioSession.sharedInstance().setCategory(.soloAmbient, mode: .default)
|
||||
}
|
||||
|
||||
player.play()
|
||||
updateDate = Date()
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ final class AudioPlaybackService: NSObject {
|
||||
try? AVAudioSession.sharedInstance().setCategory(.playback)
|
||||
try? AVAudioSession.sharedInstance().setActive(true)
|
||||
case .paused, .stopped, .failed:
|
||||
try? AVAudioSession.sharedInstance().setCategory(.soloAmbient) // reset to default
|
||||
try? AVAudioSession.sharedInstance().setCategory(.ambient) // set to ambient to allow mixed (needed for GIFV)
|
||||
try? AVAudioSession.sharedInstance().setActive(false, options: .notifyOthersOnDeactivation)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user