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()