Skip to content

bug: 재생화면 재사용 버그 수정 #244

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

Merged
merged 4 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion iOS/Layover/Layover/Network/DTOs/BoardDTO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ struct BoardDTO: Decodable {
let id: Int
let encodedVideoURL: String
let videoThumbnailURL: String
let latitude, longitude, title, content: String
let latitude, longitude: Double
let title, content: String

enum CodingKeys: String, CodingKey {
case id
Expand Down
16 changes: 8 additions & 8 deletions iOS/Layover/Layover/Network/Mock/MockData/PostList.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"id" : 1,
"encoded_video_url" : "https://assets.afcdn.com/video49/20210722/v_645516.m3u8",
"video_thumbnail_url" : "https://think-note.com/wp-content/uploads/2023/07/eta_3.jpg",
"longitude" : "37.0532156213",
"latitude" : "127.060123123",
"longitude" : 37.0532156213,
"latitude" : 127.060123123,
"title" : "최강 아이돌",
"content" : "게시글 설명"
},
Expand All @@ -32,8 +32,8 @@
"id" : 2,
"encoded_video_url" : "https://qc66zhsq1708.edge.naverncp.com/hls/fMG98EEU8c1UirV-awtm4qKJyhaHRcnDymRFlPLZbTs_/layover-station/IMG_0136_AVC_,HD,SD,_1Pass_30fps.mp4.smil/master.m3u8",
"video_thumbnail_url" : "video_thumbnail_link",
"longitude" : "37.0532156213",
"latitude" : "127.060123123",
"longitude" : 37.0532156213,
"latitude" : 127.060123123,
"title" : "프로듀스 101",
"content" : "게시글 설명"
},
Expand All @@ -50,8 +50,8 @@
"id" : 3,
"encoded_video_url" : "https://sample.vodobox.net/skate_phantom_flex_4k/skate_phantom_flex_4k.m3u8",
"video_thumbnail_url" : "https://cdnimg.melon.co.kr/resource/image/cds/musicstory/imgUrl20210831030133473.jpg/melon/quality/90/optimize",
"longitude" : "37.0532156213",
"latitude" : "127.060123123",
"longitude" : 37.0532156213,
"latitude" : 127.060123123,
"title" : "프로미스 나인",
"content" : "게시글 설명"
},
Expand All @@ -68,8 +68,8 @@
"id" : 4,
"encoded_video_url" : "https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8",
"video_thumbnail_url" : "https://res.heraldm.com/content/image/2023/04/16/20230416000040_0.jpg",
"longitude" : "37.0532156213",
"latitude" : "127.060123123",
"longitude" : 37.0532156213,
"latitude" : 127.060123123,
"title" : "아이즈원",
"content" : "게시글 설명2"
},
Expand Down
16 changes: 8 additions & 8 deletions iOS/Layover/Layover/Network/Mock/MockData/PostListMore.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"id" : 5,
"encoded_video_url" : "https://assets.afcdn.com/video49/20210722/v_645516.m3u8",
"video_thumbnail_url" : "https://think-note.com/wp-content/uploads/2023/07/eta_3.jpg",
"longitude" : "37.0532156213",
"latitude" : "127.060123123",
"longitude" : 37.0532156213,
"latitude" : 127.060123123,
"title" : "최강 아이돌",
"content" : "게시글 설명"
},
Expand All @@ -32,8 +32,8 @@
"id" : 6,
"encoded_video_url" : "https://qc66zhsq1708.edge.naverncp.com/hls/fMG98EEU8c1UirV-awtm4qKJyhaHRcnDymRFlPLZbTs_/layover-station/IMG_0136_AVC_,HD,SD,_1Pass_30fps.mp4.smil/master.m3u8",
"video_thumbnail_url" : "video_thumbnail_link",
"longitude" : "37.0532156213",
"latitude" : "127.060123123",
"longitude" : 37.0532156213,
"latitude" : 127.060123123,
"title" : "프로듀스 101",
"content" : "게시글 설명"
},
Expand All @@ -50,8 +50,8 @@
"id" : 7,
"encoded_video_url" : "https://sample.vodobox.net/skate_phantom_flex_4k/skate_phantom_flex_4k.m3u8",
"video_thumbnail_url" : "https://cdnimg.melon.co.kr/resource/image/cds/musicstory/imgUrl20210831030133473.jpg/melon/quality/90/optimize",
"longitude" : "37.0532156213",
"latitude" : "127.060123123",
"longitude" : 37.0532156213,
"latitude" : 127.060123123,
"title" : "프로미스 나인",
"content" : "게시글 설명"
},
Expand All @@ -68,8 +68,8 @@
"id" : 8,
"encoded_video_url" : "https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8",
"video_thumbnail_url" : "https://res.heraldm.com/content/image/2023/04/16/20230416000040_0.jpg",
"longitude" : "37.0532156213",
"latitude" : "127.060123123",
"longitude" : 37.0532156213,
"latitude" : 127.060123123,
"title" : "아이즈원",
"content" : "게시글 설명2"
},
Expand Down
3 changes: 2 additions & 1 deletion iOS/Layover/Layover/Scenes/Home/HomeConfigurator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ final class HomeConfigurator: Configurator {
let router = HomeRouter()
let presenter = HomePresenter()
let interactor = HomeInteractor()
let homeWorker = MockHomeWorker()
// let homeWorker = MockHomeWorker()
let homeWorker = HomeWorker()
let videoFileWorker = VideoFileWorker()

router.viewController = viewController
Expand Down
31 changes: 15 additions & 16 deletions iOS/Layover/Layover/Scenes/Playback/Cell/PlaybackCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,52 +13,51 @@ final class PlaybackCell: UICollectionViewCell {

var boardID: Int?

var playbackView: PlaybackView?
let playbackView: PlaybackView = PlaybackView()

override init(frame: CGRect) {
super.init(frame: frame)
configure()
}

required init?(coder: NSCoder) {
super.init(coder: coder)
configure()
}

override func prepareForReuse() {
resetObserver()
}

func setPlaybackContents(info: PlaybackModels.PlaybackInfo) {
playbackView = nil
boardID = info.boardID
playbackView = PlaybackView(frame: .zero, content: info.content)
playbackView?.descriptionView.titleLabel.text = info.title
configure()
playbackView?.descriptionView.setText(info.content)
playbackView?.profileLabel.text = info.profileName
playbackView?.tagStackView.resetTagStackView()
playbackView.descriptionView.titleLabel.text = info.title
playbackView.descriptionView.setText(info.content)
playbackView.setDescriptionViewUI()
playbackView.profileLabel.text = info.profileName
playbackView.tagStackView.resetTagStackView()
info.tag.forEach { tag in
playbackView?.tagStackView.addTag(tag)
playbackView.tagStackView.addTag(tag)
}
}

func addAVPlayer(url: URL) {
playbackView?.resetPlayer()
playbackView?.addAVPlayer(url: url)
playbackView?.setPlayerSlider()
playbackView.resetPlayer()
playbackView.addAVPlayer(url: url)
playbackView.setPlayerSlider()
}

func addPlayerSlider(tabBarHeight: CGFloat) {
playbackView?.addWindowPlayerSlider(tabBarHeight)
playbackView.addWindowPlayerSlider(tabBarHeight)

}

func resetObserver() {
playbackView?.removeTimeObserver()
playbackView?.removePlayerSlider()
playbackView.removeTimeObserver()
playbackView.removePlayerSlider()
}

private func configure() {
guard let playbackView else { return }
playbackView.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(playbackView)
NSLayoutConstraint.activate([
Expand Down
10 changes: 4 additions & 6 deletions iOS/Layover/Layover/Scenes/Playback/PlaybackInteractor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,15 @@ final class PlaybackInteractor: PlaybackBusinessLogic, PlaybackDataStore {
}

func controlPlaybackMovie(with request: PlaybackModels.SeekVideo.Request) {
guard let prevCell,
let playbackView = prevCell.playbackView
else { return }
let willMoveLocation: Float64 = request.currentLocation * playbackView.getDuration()
guard let prevCell else { return }
let willMoveLocation: Float64 = request.currentLocation * prevCell.playbackView.getDuration()
let response: Models.SeekVideo.Response = Models.SeekVideo.Response(willMoveLocation: willMoveLocation, curCell: prevCell)
presenter?.presentSeekVideo(with: response)
}

func hidePlayerSlider() {
guard let prevCell else { return }
prevCell.playbackView?.playerSlider?.isHidden = true
prevCell.playbackView.playerSlider?.isHidden = true
}

func setSeeMoreButton() {
Expand Down Expand Up @@ -216,6 +214,6 @@ final class PlaybackInteractor: PlaybackBusinessLogic, PlaybackDataStore {

func resumeVideo() {
guard let prevCell else { return }
prevCell.playbackView?.playPlayer()
prevCell.playbackView.playPlayer()
}
}
41 changes: 17 additions & 24 deletions iOS/Layover/Layover/Scenes/Playback/PlaybackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ final class PlaybackView: UIView {

// MARK: - Properties

var descriptionContent: String

private var timeObserverToken: Any?

private var playerObserverToken: Any?
Expand All @@ -23,7 +21,7 @@ final class PlaybackView: UIView {
// TODO: private 다시 붙이고 Method 처리
lazy var descriptionView: LODescriptionView = {
let descriptionView: LODescriptionView = LODescriptionView()
descriptionView.setText(descriptionContent)
descriptionView.setText("임시내용임")
descriptionView.clipsToBounds = true
return descriptionView
}()
Expand Down Expand Up @@ -92,19 +90,15 @@ final class PlaybackView: UIView {

// MARK: - View Life Cycle

init(frame: CGRect, content: String) {
self.descriptionContent = content
override init(frame: CGRect) {
super.init(frame: frame)
setUI()
// addDescriptionAnimateGesture()
setPlayerView()
}

required init?(coder: NSCoder) {
self.descriptionContent = ""
super.init(coder: coder)
setUI()
// addDescriptionAnimateGesture()
setPlayerView()
}

Expand Down Expand Up @@ -181,6 +175,21 @@ final class PlaybackView: UIView {
playerView.player?.removeTimeObserver(timeObserverToken)
}
}

func setDescriptionViewUI() {
if descriptionView.checkLabelOverflow() {
let size: CGSize = CGSize(width: LODescriptionView.descriptionWidth, height: .infinity)
let estimatedSize: CGSize = descriptionView.descriptionLabel.sizeThatFits(size)
let totalHeight: CGFloat = estimatedSize.height + descriptionView.titleLabel.intrinsicContentSize.height
descriptionView.heightAnchor.constraint(equalToConstant: totalHeight).isActive = true
descriptionView.titleLabel.topAnchor.constraint(equalTo: descriptionView.topAnchor, constant: totalHeight - LODescriptionView.descriptionHeight).isActive = true
descriptionView.descriptionLabel.layer.addSublayer(gradientLayer)
addDescriptionAnimateGesture()
} else {
descriptionView.heightAnchor.constraint(equalToConstant: LODescriptionView.descriptionHeight).isActive = true
descriptionView.titleLabel.topAnchor.constraint(equalTo: descriptionView.topAnchor).isActive = true
}
}
}

// MARK: PlaybackView 내부에서만 쓰이는 Method
Expand Down Expand Up @@ -210,21 +219,6 @@ private extension PlaybackView {

// MARK: - UI Method

func setDescriptionViewUI() {
if descriptionView.checkLabelOverflow() {
let size: CGSize = CGSize(width: LODescriptionView.descriptionWidth, height: .infinity)
let estimatedSize: CGSize = descriptionView.descriptionLabel.sizeThatFits(size)
let totalHeight: CGFloat = estimatedSize.height + descriptionView.titleLabel.intrinsicContentSize.height
descriptionView.heightAnchor.constraint(equalToConstant: totalHeight).isActive = true
descriptionView.titleLabel.topAnchor.constraint(equalTo: descriptionView.topAnchor, constant: totalHeight - LODescriptionView.descriptionHeight).isActive = true
descriptionView.descriptionLabel.layer.addSublayer(gradientLayer)
addDescriptionAnimateGesture()
} else {
descriptionView.heightAnchor.constraint(equalToConstant: LODescriptionView.descriptionHeight).isActive = true
descriptionView.titleLabel.topAnchor.constraint(equalTo: descriptionView.topAnchor).isActive = true
}
}

func setSubViewsInPlayerViewConstraints() {
[descriptionView, tagStackView, profileButton, profileLabel, locationLabel, pauseImage, playImage].forEach { subView in
subView.translatesAutoresizingMaskIntoConstraints = false
Expand Down Expand Up @@ -260,7 +254,6 @@ private extension PlaybackView {
playImage.widthAnchor.constraint(equalToConstant: 65),
playImage.heightAnchor.constraint(equalToConstant: 65)
])
setDescriptionViewUI()
}

func setUI() {
Expand Down
21 changes: 11 additions & 10 deletions iOS/Layover/Layover/Scenes/Playback/PlaybackViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ final class PlaybackViewController: BaseViewController {
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
interactor?.leavePlaybackView()
interactor?.hidePlayerSlider()
if isMovingFromParent {
interactor?.resetVideo()
}
Expand Down Expand Up @@ -186,14 +187,14 @@ extension PlaybackViewController: PlaybackDisplayLogic {
func stopPrevPlayerAndPlayCurPlayer(viewModel: PlaybackModels.DisplayPlaybackVideo.ViewModel) {
guard let tabBarHeight: CGFloat = self.tabBarController?.tabBar.frame.height else { return }
if let prevCell = viewModel.prevCell {
prevCell.playbackView?.removePlayerSlider()
prevCell.playbackView?.stopPlayer()
prevCell.playbackView?.replayPlayer()
prevCell.playbackView.removePlayerSlider()
prevCell.playbackView.stopPlayer()
prevCell.playbackView.replayPlayer()
}
if let curCell = viewModel.curCell {
curCell.addPlayerSlider(tabBarHeight: tabBarHeight)
curCell.playbackView?.addTargetPlayerSlider()
curCell.playbackView?.playPlayer()
curCell.playbackView.addTargetPlayerSlider()
curCell.playbackView.playPlayer()
}
}

Expand All @@ -206,7 +207,7 @@ extension PlaybackViewController: PlaybackDisplayLogic {
}

func showPlayerSlider(viewModel: PlaybackModels.DisplayPlaybackVideo.ViewModel) {
viewModel.curCell?.playbackView?.playerSlider?.isHidden = false
viewModel.curCell?.playbackView.playerSlider?.isHidden = false
}

func moveInitialPlaybackCell(viewModel: PlaybackModels.SetInitialPlaybackCell.ViewModel) {
Expand All @@ -221,7 +222,7 @@ extension PlaybackViewController: PlaybackDisplayLogic {
}

func leavePlaybackView(viewModel: PlaybackModels.DisplayPlaybackVideo.ViewModel) {
viewModel.prevCell?.playbackView?.stopPlayer()
viewModel.prevCell?.playbackView.stopPlayer()
}

func configureDataSource(viewModel: PlaybackModels.ConfigurePlaybackCell.ViewModel) {
Expand All @@ -241,14 +242,14 @@ extension PlaybackViewController: PlaybackDisplayLogic {

func seekVideo(viewModel: PlaybackModels.SeekVideo.ViewModel) {
let seekTime: CMTime = CMTime(value: CMTimeValue(viewModel.willMoveLocation), timescale: 1)
viewModel.curCell.playbackView?.seekPlayer(seekTime: seekTime)
viewModel.curCell.playbackView?.playPlayer()
viewModel.curCell.playbackView.seekPlayer(seekTime: seekTime)
viewModel.curCell.playbackView.playPlayer()
}

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

Expand Down