From 9be22e449981b29b1b023ad7a649c4334d526d3b Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Wed, 26 Feb 2025 14:16:37 +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-=2010=EC=B4=88=20=EC=9D=B4?= =?UTF-8?q?=EC=A0=84/=EC=9D=B4=ED=9B=84=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= =?UTF-8?q?=ED=95=98=EB=8A=94=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 --- .../Content/Player/ContentPlayerPlayManager.swift | 13 +++++++++++++ .../Sources/Content/Player/ContentPlayerView.swift | 14 ++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/SodaLive/Sources/Content/Player/ContentPlayerPlayManager.swift b/SodaLive/Sources/Content/Player/ContentPlayerPlayManager.swift index cc61f56..300adb5 100644 --- a/SodaLive/Sources/Content/Player/ContentPlayerPlayManager.swift +++ b/SodaLive/Sources/Content/Player/ContentPlayerPlayManager.swift @@ -219,6 +219,19 @@ final class ContentPlayerPlayManager: NSObject, ObservableObject { player?.seek(to: cmTime) } + func seekBackward(seconds: Double) { + guard let currentTime = player?.currentTime() else { return } + let newTimeInSeconds = CMTimeGetSeconds(currentTime) - seconds + seek(to: max(newTimeInSeconds, 0)) + } + + func seekForward(seconds: Double) { + guard let currentTime = player?.currentTime(), let duration = player?.currentItem?.duration else { return } + let newTimeInSeconds = CMTimeGetSeconds(currentTime) + seconds + let durationInSeconds = CMTimeGetSeconds(duration) + seek(to: min(newTimeInSeconds, durationInSeconds)) + } + private func generateUrl(contentId: Int, onSuccess: @escaping (String) -> Void, onFailure: @escaping () -> Void) { if contentId < 0 { onFailure() diff --git a/SodaLive/Sources/Content/Player/ContentPlayerView.swift b/SodaLive/Sources/Content/Player/ContentPlayerView.swift index 1148f83..61ab002 100644 --- a/SodaLive/Sources/Content/Player/ContentPlayerView.swift +++ b/SodaLive/Sources/Content/Player/ContentPlayerView.swift @@ -119,6 +119,13 @@ struct ContentPlayerView: View { Spacer() + Image("ic_player_prev_10") + .onTapGesture { + playerManager.seekBackward(seconds: 10) + } + + Spacer() + Image(playerManager.isPlaying ? "ic_player_pause" : "ic_player_play") .onTapGesture { playerManager.playOrPause() @@ -126,6 +133,13 @@ struct ContentPlayerView: View { Spacer() + Image("ic_player_next_10") + .onTapGesture { + playerManager.seekForward(seconds: 10) + } + + Spacer() + Image("ic_skip_forward") .onTapGesture { playerManager.playNextContent()