From 51fcb8835e4e59e7dbd0a5e1162eae72774b40d3 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Tue, 8 Apr 2025 12:37:57 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BD=98=ED=85=90=EC=B8=A0=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20-=2010=EC=B4=88=20=EC=A0=84/=ED=9B=84=EB=A1=9C=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Content/ContentPlayManager.swift | 18 +++++- .../Detail/ContentDetailPlayView.swift | 62 ++++++++++++------- 2 files changed, 56 insertions(+), 24 deletions(-) diff --git a/SodaLive/Sources/Content/ContentPlayManager.swift b/SodaLive/Sources/Content/ContentPlayManager.swift index 22c474c..a5cb26e 100644 --- a/SodaLive/Sources/Content/ContentPlayManager.swift +++ b/SodaLive/Sources/Content/ContentPlayManager.swift @@ -16,7 +16,7 @@ final class ContentPlayManager: NSObject, ObservableObject { var creatorId = 0 @Published var contentId: Int = 0 - @Published private (set) var duration: TimeInterval = 0 + @Published private(set) var duration: TimeInterval = 0 @Published var title = "" @Published var nickname = "" @@ -24,8 +24,8 @@ final class ContentPlayManager: NSObject, ObservableObject { @Published var isFree: Bool? = nil @Published var isPreview: Bool? = nil - @Published private (set) var isShowingMiniPlayer = false - @Published private (set) var isPlaying = false + @Published private(set) var isShowingMiniPlayer = false + @Published private(set) var isPlaying = false @Published var isLoading = false @Published var errorMessage = "" @@ -170,6 +170,18 @@ extension ContentPlayManager { } } + func seekBackward10Seconds() { + guard let player = player else { return } + let newTime = max(player.currentTime - 10, 0) + player.currentTime = newTime + } + + func seekForward10Seconds() { + guard let player = player else { return } + let newTime = min(player.currentTime + 10, player.duration) + player.currentTime = newTime + } + private func repeatAudio() { if let stopTimer = stopTimer { stopTimer() diff --git a/SodaLive/Sources/Content/Detail/ContentDetailPlayView.swift b/SodaLive/Sources/Content/Detail/ContentDetailPlayView.swift index 7a14f8c..e271372 100644 --- a/SodaLive/Sources/Content/Detail/ContentDetailPlayView.swift +++ b/SodaLive/Sources/Content/Detail/ContentDetailPlayView.swift @@ -53,28 +53,48 @@ struct ContentDetailPlayView: View { ) .background(Color.black.opacity(0.6)) } else if audioContent.releaseDate == nil && !isAlertPreview || (audioContent.isActivePreview && !audioContent.contentUrl.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty) { - Image(isPlaying() ? "btn_audio_content_pause" : isAlertPreview ? "btn_audio_content_preview_play" : "btn_audio_content_play") - .onTapGesture { - ContentPlayerPlayManager.shared.resetPlayer() - - if isPlaying() { - contentPlayManager.pauseAudio() - } else { - contentPlayManager.startTimer = startTimer - contentPlayManager.stopTimer = stopTimer - - contentPlayManager.playAudio( - contentId: audioContent.contentId, - title: audioContent.title, - nickname: audioContent.creator.nickname, - coverImage: audioContent.coverImageUrl, - contentUrl: audioContent.contentUrl, - isFree: audioContent.price <= 0, - isPreview: !audioContent.existOrdered && audioContent.price > 0 - ) - isShowPreviewAlert = true - } + HStack(spacing: 24) { + if !isAlertPreview { + Image("ic_player_prev_10") + .onTapGesture { + if isPlaying() { + contentPlayManager.seekBackward10Seconds() + } + } } + + Image(isPlaying() ? "btn_audio_content_pause" : isAlertPreview ? "btn_audio_content_preview_play" : "btn_audio_content_play") + .onTapGesture { + ContentPlayerPlayManager.shared.resetPlayer() + + if isPlaying() { + contentPlayManager.pauseAudio() + } else { + contentPlayManager.startTimer = startTimer + contentPlayManager.stopTimer = stopTimer + + contentPlayManager.playAudio( + contentId: audioContent.contentId, + title: audioContent.title, + nickname: audioContent.creator.nickname, + coverImage: audioContent.coverImageUrl, + contentUrl: audioContent.contentUrl, + isFree: audioContent.price <= 0, + isPreview: !audioContent.existOrdered && audioContent.price > 0 + ) + isShowPreviewAlert = true + } + } + + if !isAlertPreview { + Image("ic_player_next_10") + .onTapGesture { + if isPlaying() { + contentPlayManager.seekForward10Seconds() + } + } + } + } } else if audioContent.releaseDate == nil { Text("해당 콘텐츠는 크리에이터의 요청으로\n미리듣기를 제공하지 않습니다.") .font(.custom(Font.medium.rawValue, size: 16.7))