diff --git a/SodaLive/Sources/Content/Player/ContentPlayerPlayManager.swift b/SodaLive/Sources/Content/Player/ContentPlayerPlayManager.swift index 5f54e26..34641b1 100644 --- a/SodaLive/Sources/Content/Player/ContentPlayerPlayManager.swift +++ b/SodaLive/Sources/Content/Player/ContentPlayerPlayManager.swift @@ -70,6 +70,7 @@ final class ContentPlayerPlayManager: NSObject, ObservableObject { .sink { [weak self] currentTime in if !(self?.isEditing ?? false) { self?.currentTime = CMTimeGetSeconds(currentTime) + MPNowPlayingInfoCenter.default().nowPlayingInfo?[MPNowPlayingInfoPropertyElapsedPlaybackTime] = self?.currentTime } } .store(in: &cancellables) @@ -114,8 +115,8 @@ final class ContentPlayerPlayManager: NSObject, ObservableObject { try audioSession.setCategory(.playback, mode: .moviePlayback) try audioSession.setActive(true) - self.registerRemoteControlEvents() self.fetchAlbumArtAndUpdateNowPlayingInfo() + self.registerRemoteControlEvents() } catch { DEBUG_LOG("Audio Session 설정 실패: \(error.localizedDescription)") } @@ -180,7 +181,7 @@ final class ContentPlayerPlayManager: NSObject, ObservableObject { } func playOrPause() { - if player?.timeControlStatus == .paused { + if player?.timeControlStatus == .paused && !isPlaying { player?.play() isPlaying = true } else { @@ -276,7 +277,7 @@ final class ContentPlayerPlayManager: NSObject, ObservableObject { switch result { case .success(let value): self?.registerNowPlayingInfoCenter(with: value.image) - case .failure(let error): + case .failure(_): self?.registerNowPlayingInfoCenter(with: nil) } } @@ -284,7 +285,7 @@ final class ContentPlayerPlayManager: NSObject, ObservableObject { private func registerNowPlayingInfoCenter(with albumArtImage: UIImage?) { let center = MPNowPlayingInfoCenter.default() - var nowPlayingInfo = center.nowPlayingInfo ?? [String: Any]() + var nowPlayingInfo = [String: Any]() nowPlayingInfo[MPMediaItemPropertyTitle] = title nowPlayingInfo[MPMediaItemPropertyArtist] = nickname @@ -294,11 +295,8 @@ final class ContentPlayerPlayManager: NSObject, ObservableObject { nowPlayingInfo[MPMediaItemPropertyArtwork] = artwork } - nowPlayingInfo[MPMediaItemPropertyPlaybackDuration] = duration - nowPlayingInfo[MPNowPlayingInfoPropertyElapsedPlaybackTime] = currentTime - if let player = player { - // 콘텐츠 재생 시간에 따른 progressBar 초기화 + nowPlayingInfo[MPMediaItemPropertyPlaybackDuration] = player.currentItem?.duration.seconds nowPlayingInfo[MPNowPlayingInfoPropertyPlaybackRate] = player.rate } @@ -319,9 +317,6 @@ final class ContentPlayerPlayManager: NSObject, ObservableObject { self.playOrPause() return .success } - - center.seekForwardCommand.isEnabled = false - center.seekBackwardCommand.isEnabled = false } private func unRegisterRemoteControlEvents() {