Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: 재생화면 버그 수정 #215

Merged
merged 10 commits into from
Dec 6, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ final class HomeCarouselCollectionViewCell: UICollectionViewCell {
loopingPlayerView.pause()
}

func resetVideo() {
loopingPlayerView.reset()
}

// MARK: - Actions

@objc private func tagButtonDidTap(_ sender: UIButton) {
Expand Down
2 changes: 1 addition & 1 deletion iOS/Layover/Layover/Scenes/Home/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ final class HomeViewController: BaseViewController {
private func pauseAllVisibleCellsVideo() {
carouselCollectionView.visibleCells.forEach { cell in
guard let cell = cell as? HomeCarouselCollectionViewCell else { return }
cell.pauseVideo()
cell.resetVideo()
}
}

Expand Down
6 changes: 6 additions & 0 deletions iOS/Layover/Layover/Scenes/Playback/PlaybackInteractor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ protocol PlaybackBusinessLogic {
func playInitialPlaybackCell(with request: PlaybackModels.DisplayPlaybackVideo.Request)
func playVideo(with request: PlaybackModels.DisplayPlaybackVideo.Request)
func playTeleportVideo(with request: PlaybackModels.DisplayPlaybackVideo.Request)
func moveToBack()
func configurePlaybackCell()
func controlPlaybackMovie(with request: PlaybackModels.SeekVideo.Request)
}
Expand Down Expand Up @@ -141,6 +142,11 @@ final class PlaybackInteractor: PlaybackBusinessLogic, PlaybackDataStore {
presenter?.presentLeavePlaybackView(with: response)
}

func moveToBack() {
let response: Models.DisplayPlaybackVideo.Response = Models.DisplayPlaybackVideo.Response(prevCell: nil, curCell: prevCell)
presenter?.presentResetPlaybackCell(with: response)
}

func configurePlaybackCell() {
guard let posts,
let parentView else { return }
Expand Down
2 changes: 1 addition & 1 deletion iOS/Layover/Layover/Scenes/Playback/PlaybackModels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ enum PlaybackModels {

struct ViewModel {
let indexPathRow: Int?
let prevCell: PlaybackCell?
var prevCell: PlaybackCell?
let curCell: PlaybackCell?

init(indexPathRow: Int? = nil, prevCell: PlaybackCell?, curCell: PlaybackCell?) {
Expand Down
10 changes: 10 additions & 0 deletions iOS/Layover/Layover/Scenes/Playback/PlaybackPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ protocol PlaybackPresentationLogic {
func presentShowPlayerSlider(with response: PlaybackModels.DisplayPlaybackVideo.Response)
func presentTeleportCell(with response: PlaybackModels.DisplayPlaybackVideo.Response)
func presentLeavePlaybackView(with response: PlaybackModels.DisplayPlaybackVideo.Response)
func presentResetPlaybackCell(with response: PlaybackModels.DisplayPlaybackVideo.Response)
func presentConfigureCell(with response: PlaybackModels.ConfigurePlaybackCell.Response)
func presentSeekVideo(with response: PlaybackModels.SeekVideo.Response)
}
Expand Down Expand Up @@ -93,11 +94,20 @@ final class PlaybackPresenter: PlaybackPresentationLogic {
viewController?.leavePlaybackView(viewModel: viewModel)
}

func presentResetPlaybackCell(with response: PlaybackModels.DisplayPlaybackVideo.Response) {
let viewModel: Models.DisplayPlaybackVideo.ViewModel = Models.DisplayPlaybackVideo.ViewModel(prevCell: nil, curCell: response.curCell)
viewController?.routeToBack(viewModel: viewModel)
}

// MARK: - UseCase Configure Playback Cell

func presentConfigureCell(with response: PlaybackModels.ConfigurePlaybackCell.Response) {
let viewModel: Models.ConfigurePlaybackCell.ViewModel = Models.ConfigurePlaybackCell.ViewModel(teleportIndex: response.teleportIndex)
viewController?.configureDataSource(viewModel: viewModel)
}

// MARK: - UseCase Seek Video

func presentSeekVideo(with response: PlaybackModels.SeekVideo.Response) {
let viewModel: Models.SeekVideo.ViewModel = Models.SeekVideo.ViewModel(willMoveLocation: response.willMoveLocation, curCell: response.curCell)
viewController?.seekVideo(viewModel: viewModel)
Expand Down
6 changes: 3 additions & 3 deletions iOS/Layover/Layover/Scenes/Playback/PlaybackRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import UIKit

protocol PlaybackRoutingLogic {
func routeToNext()
func routeToBack()
}

protocol PlaybackDataPassing {
Expand All @@ -25,7 +25,7 @@ final class PlaybackRouter: NSObject, PlaybackRoutingLogic, PlaybackDataPassing

// MARK: - Routing

func routeToNext() {

func routeToBack() {
viewController?.navigationController?.popViewController(animated: true)
}
}
20 changes: 17 additions & 3 deletions iOS/Layover/Layover/Scenes/Playback/PlaybackViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ protocol PlaybackDisplayLogic: AnyObject {
func showPlayerSlider(viewModel: PlaybackModels.DisplayPlaybackVideo.ViewModel)
func teleportPlaybackCell(viewModel: PlaybackModels.DisplayPlaybackVideo.ViewModel)
func leavePlaybackView(viewModel: PlaybackModels.DisplayPlaybackVideo.ViewModel)
func routeToBack(viewModel: PlaybackModels.DisplayPlaybackVideo.ViewModel)
func configureDataSource(viewModel: PlaybackModels.ConfigurePlaybackCell.ViewModel)
func seekVideo(viewModel: PlaybackModels.SeekVideo.ViewModel)
}
Expand Down Expand Up @@ -91,6 +92,10 @@ final class PlaybackViewController: BaseViewController {
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
interactor?.leavePlaybackView()
if isMovingFromParent {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isMovingFromParent .. 뷰컨에 이런 프로퍼티가 있군요..?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

근데 얘 역할이 몬가요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

viewWillDisappear되는 경우가 두가지가 있습니다. 하나는 backbutton눌러서 이동할 때고 다른 하나는 Tabbar로 이동하는 경우입니다.
backbutton눌러서 이동할 때는 pop을 하기 때문에 화면이 아예 사라지는 경우(isMovingFromParent)이기 때문에 player나 observer를 아예 초기화 시키구요.
Tabbar로 이동할 때는 아예 나가는게 아닌 탭만 이동하는 동작으로 처리합니다.
예를 들어 홈탭에서 영상을 보다 지도탭으로 들어간 후, 다시 홈탭으로 돌아오면 홈탭에서 보던 영상이 다시 재생됩니다. 그 구분을 위한 역할 입니다.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이해했습니다 !! 새로운 걸 알아가요..

playerSlider.removeFromSuperview()
interactor?.moveToBack()
}
}

override func viewDidLayoutSubviews() {
Expand Down Expand Up @@ -157,6 +162,11 @@ final class PlaybackViewController: BaseViewController {
let request: Models.SeekVideo.Request = Models.SeekVideo.Request(currentLocation: Float64(sender.value))
interactor?.controlPlaybackMovie(with: request)
}

private func moveToBackViewController() {
playerSlider.removeFromSuperview()
interactor?.moveToBack()
}
}

extension PlaybackViewController: PlaybackDisplayLogic {
Expand All @@ -180,9 +190,6 @@ extension PlaybackViewController: PlaybackDisplayLogic {
curCell.playbackView.playPlayer()
setPlayerSlider(at: curCell.playbackView)
// Slider가 원점으로 돌아가는 시간 필요
// DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1) {
// self.playerSlider.isHidden = false
// }
Task {
await slowShowPlayerSlider()
}
Expand Down Expand Up @@ -238,6 +245,13 @@ extension PlaybackViewController: PlaybackDisplayLogic {
viewModel.curCell.playbackView.seekPlayer(seekTime: seekTime)
viewModel.curCell.playbackView.playPlayer()
}

func routeToBack(viewModel: PlaybackModels.DisplayPlaybackVideo.ViewModel) {
var curCell = viewModel.curCell
curCell?.playbackView.resetPlayer()
curCell = nil
}

}

extension PlaybackViewController: UICollectionViewDelegateFlowLayout {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ final class LoopingPlayerView: UIView {
player?.pause()
}
}

func reset() {
player?.replaceCurrentItem(with: nil)
player = nil
looper = nil
}
}

#Preview {
Expand Down