mirror of
https://github.com/yattee/yattee.git
synced 2025-11-20 17:02:21 +00:00
Fix iOS Now Playing integration for MPV backend
The MPV backend now properly displays Now Playing information in iOS Control Center. The fix addresses the issue where the AVAudioSession would become inactive during MPV's playback lifecycle. Key changes: - Added setupAudioSessionForNowPlaying() method to activate AVAudioSession with proper playback category and movie playback mode - Re-activate audio session at critical MPV events: FILE_LOADED, PLAYBACK_RESTART, AUDIO_RECONFIG, and during periodic updates - Initialize audio session immediately after mpv_initialize() in MPVClient The audio session must be re-activated at multiple points during playback, not just at initialization, to ensure iOS recognizes the app as playing media.
This commit is contained in:
@@ -1149,6 +1149,19 @@ final class PlayerModel: ObservableObject {
|
||||
}
|
||||
}
|
||||
|
||||
func setupAudioSessionForNowPlaying() {
|
||||
#if !os(macOS)
|
||||
do {
|
||||
let audioSession = AVAudioSession.sharedInstance()
|
||||
try audioSession.setCategory(.playback, mode: .moviePlayback, options: [])
|
||||
try audioSession.setActive(true, options: [])
|
||||
logger.info("Audio session activated for Now Playing")
|
||||
} catch {
|
||||
logger.error("Failed to set up audio session: \(error)")
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
func updateCurrentArtwork() {
|
||||
guard let video = currentVideo,
|
||||
let thumbnailURL = video.thumbnailURL(quality: Constants.isIPhone ? .medium : .maxres)
|
||||
|
||||
Reference in New Issue
Block a user