Skip to content

Commit

Permalink
[FEAT]: 영상 재생이 끝나면 처음으로 돌아가도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
LURKS02 committed Dec 5, 2024
1 parent 991beed commit 02f820d
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ private extension VideoPlayerView {
// MARK: - Binding
private extension VideoPlayerView {
func setupViewBinding() {
NotificationCenter.default
.publisher(for: .AVPlayerItemDidPlayToEndTime, object: player.currentItem)
.sink(with: self) { owner, _ in
owner.handleVideoCompletion()
}
.store(in: &cancellables)

// Thanks to LURKS02
playPauseButton.publisher(for: .touchUpInside)
.receive(on: DispatchQueue.main)
Expand Down Expand Up @@ -196,4 +203,13 @@ private extension VideoPlayerView {
let seekTime = CMTime(seconds: newTime, preferredTimescale: 1)
player.seek(to: seekTime)
}

func handleVideoCompletion() {
seekingSlider.value = 100

let image = UIImage(systemName: "play.circle.fill")
playPauseButton.setImage(image, for: .normal)

player.seek(to: .zero)
}
}

0 comments on commit 02f820d

Please sign in to comment.