From fb1bac83ae33aef4d762f68473344f4b46de41b4 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Wed, 18 Dec 2024 16:02:42 +0900 Subject: [PATCH] =?UTF-8?q?=ED=94=8C=EB=A0=88=EC=9D=B4=EC=96=B4,=20?= =?UTF-8?q?=EC=9E=AC=EC=83=9D=EB=AA=A9=EB=A1=9D=20=EC=BD=98=ED=85=90?= =?UTF-8?q?=EC=B8=A0=20=EC=B6=94=EA=B0=80/=EC=A0=9C=EA=B1=B0=20-=20?= =?UTF-8?q?=EB=A7=8C=EB=A3=8C=EB=90=9C=20=EC=BD=98=ED=85=90=EC=B8=A0?= =?UTF-8?q?=EB=8A=94=20=EC=9E=AC=EC=83=9D=EB=90=98=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EA=B3=A0=20=EB=8B=A4=EC=9D=8C=20=EC=BD=98=ED=85=90=EC=B8=A0?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B4=EB=8F=99=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20-=20=EC=95=84=EC=9D=B4=ED=85=9C=20?= =?UTF-8?q?=ED=84=B0=EC=B9=98=20=EC=98=81=EC=97=AD=EC=9D=84=20=EC=95=84?= =?UTF-8?q?=EC=9D=B4=ED=85=9C=20=EC=A0=84=EC=B2=B4=EB=A1=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Player/ContentPlayerPlayManager.swift | 22 ++++++++----------- .../Create/PlaylistAddContentItemView.swift | 1 + 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/SodaLive/Sources/Content/Player/ContentPlayerPlayManager.swift b/SodaLive/Sources/Content/Player/ContentPlayerPlayManager.swift index b638f19..dfe0b6c 100644 --- a/SodaLive/Sources/Content/Player/ContentPlayerPlayManager.swift +++ b/SodaLive/Sources/Content/Player/ContentPlayerPlayManager.swift @@ -138,7 +138,11 @@ final class ContentPlayerPlayManager: NSObject, ObservableObject { } private func handlePlaybackEnded() { - playNextContent() + if let hasNextContent = self.playlistManager?.hasNextContent(), hasNextContent { + self.playNextContent() + } else { + self.stop() + } } func playNextContent() { @@ -148,11 +152,7 @@ final class ContentPlayerPlayManager: NSObject, ObservableObject { generateUrl(contentId: content.id) { [unowned self] url in self.urlGenerateSuccess(content: content, url: url) } onFailure: { - if let hasNextContent = self.playlistManager?.hasNextContent(), hasNextContent { - self.playNextContent() - } else { - self.stop() - } + self.playNextContent() } } } @@ -164,11 +164,7 @@ final class ContentPlayerPlayManager: NSObject, ObservableObject { generateUrl(contentId: content.id) { [unowned self] url in self.urlGenerateSuccess(content: content, url: url) } onFailure: { - if let hasNextContent = self.playlistManager?.hasNextContent(), hasNextContent { - self.playNextContent() - } else { - self.stop() - } + self.playPreviousContent() } } } @@ -196,12 +192,12 @@ final class ContentPlayerPlayManager: NSObject, ObservableObject { isLoading = false player?.pause() player?.seek(to: .zero) - duration = 0 currentTime = 0 } func resetPlayer() { stop() + duration = 0 isShowingMiniPlayer = false title = "" @@ -243,7 +239,7 @@ final class ContentPlayerPlayManager: NSObject, ObservableObject { let jsonDecoder = JSONDecoder() let decoded = try jsonDecoder.decode(ApiResponse.self, from: responseData) - if let data = decoded.data, decoded.success { + if let data = decoded.data, !data.contentUrl.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty, decoded.success { onSuccess(data.contentUrl) } else { self.isLoading = false diff --git a/SodaLive/Sources/Content/Playlist/Create/PlaylistAddContentItemView.swift b/SodaLive/Sources/Content/Playlist/Create/PlaylistAddContentItemView.swift index 6f7d7be..8b1b82b 100644 --- a/SodaLive/Sources/Content/Playlist/Create/PlaylistAddContentItemView.swift +++ b/SodaLive/Sources/Content/Playlist/Create/PlaylistAddContentItemView.swift @@ -62,6 +62,7 @@ struct PlaylistAddContentItemView: View { Image(isChecked ? "ic_check_blue" : "ic_playlist_add") .padding(8) } + .contentShape(Rectangle()) .onTapGesture { onClick() isChecked.toggle()