From ee22a0a77e7838248e790e5d8361736f3e6f5b2a Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Wed, 26 Feb 2025 17:20:12 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BD=98=ED=85=90=EC=B8=A0=20=ED=94=8C?= =?UTF-8?q?=EB=A0=88=EC=9D=B4=EC=96=B4=20-=20=EC=9E=AC=EC=83=9D=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20-=20=EC=95=84=EC=9D=B4=ED=85=9C=EC=9D=84=20?= =?UTF-8?q?=ED=84=B0=EC=B9=98=ED=96=88=EC=9D=84=20=EB=95=8C=20=ED=98=84?= =?UTF-8?q?=EC=9E=AC=20index=EB=8F=84=20=EA=B0=99=EC=9D=B4=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=EB=90=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=ED=95=B4=EC=84=9C=20=EC=9D=B4=EC=A0=84/=EC=9D=B4=ED=9B=84=20?= =?UTF-8?q?=EC=9E=AC=EC=83=9D=EC=8B=9C=20=ED=98=84=EC=9E=AC=20=EC=95=84?= =?UTF-8?q?=EC=9D=B4=ED=85=9C=20=EA=B8=B0=EC=A4=80=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=9D=B4=EC=A0=84/=EC=9D=B4=ED=9B=84=20=EC=BD=98=ED=85=90?= =?UTF-8?q?=EC=B8=A0=EA=B0=80=20=EC=9E=AC=EC=83=9D=EB=90=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Content/Player/AudioContentPlaylistManager.swift | 9 +++++++++ .../Content/Player/ContentPlayerPlayManager.swift | 4 ++-- SodaLive/Sources/Content/Player/ContentPlayerView.swift | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/SodaLive/Sources/Content/Player/AudioContentPlaylistManager.swift b/SodaLive/Sources/Content/Player/AudioContentPlaylistManager.swift index 0817071..f08dae3 100644 --- a/SodaLive/Sources/Content/Player/AudioContentPlaylistManager.swift +++ b/SodaLive/Sources/Content/Player/AudioContentPlaylistManager.swift @@ -34,6 +34,15 @@ class AudioContentPlaylistManager { return nil } + func findByContentId(contentId: Int) -> AudioContentPlaylistContent? { + if let index = playlist.firstIndex(where: { $0.id == contentId }), !playlist.isEmpty { + currentIndex = index + return playlist[index] + } + + return nil + } + func hasNextContent() -> Bool { return currentIndex + 1 < playlist.count } diff --git a/SodaLive/Sources/Content/Player/ContentPlayerPlayManager.swift b/SodaLive/Sources/Content/Player/ContentPlayerPlayManager.swift index 5684068..c32fb10 100644 --- a/SodaLive/Sources/Content/Player/ContentPlayerPlayManager.swift +++ b/SodaLive/Sources/Content/Player/ContentPlayerPlayManager.swift @@ -174,8 +174,8 @@ final class ContentPlayerPlayManager: NSObject, ObservableObject { } } - func playSelectedContent(content: AudioContentPlaylistContent) { - if content.id != id { + func playSelectedContent(contentId: Int) { + if let content = playlistManager?.findByContentId(contentId: contentId) { generateUrl(contentId: content.id) { [unowned self] url in self.urlGenerateSuccess(content: content, url: url) } onFailure: { diff --git a/SodaLive/Sources/Content/Player/ContentPlayerView.swift b/SodaLive/Sources/Content/Player/ContentPlayerView.swift index f9777c5..5b610d0 100644 --- a/SodaLive/Sources/Content/Player/ContentPlayerView.swift +++ b/SodaLive/Sources/Content/Player/ContentPlayerView.swift @@ -51,7 +51,7 @@ struct ContentPlayerView: View { .padding(.top, 21) } - Spacer() + Spacer(minLength: 13.3) if playerManager.isShowPlaylist { ScrollView(.vertical) { @@ -69,7 +69,7 @@ struct ContentPlayerView: View { ) .cornerRadius(6.7) .onTapGesture { - playerManager.playSelectedContent(content: item) + playerManager.playSelectedContent(contentId: item.id) } } }