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

[Attempt-02] Attempt-01 Scale Value 조정 Ver #2

Closed
jeong-hyeonHwang opened this issue Feb 2, 2023 · 0 comments
Closed

[Attempt-02] Attempt-01 Scale Value 조정 Ver #2

jeong-hyeonHwang opened this issue Feb 2, 2023 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@jeong-hyeonHwang
Copy link
Owner

Custom Video Player: 두 번째 시도

구현 결과

CustomVideoPlayer02.MP4

첫 번째 시도에서 VideoPlayerControlView에서의 버튼 스케일 관련 이슈 해결을 위해 아래의 것들을 시도

1. ViewController Hierarchy 재작성

  • UIView 각각에 Scale 변환을 따로, 수치 계산 없이 비교적 쉽게(.....) 적용하기 위함
전체 구조도
ViewController2 OnlyVideoPlayerView VideoPlayerControlView
Component Description
ViewController2 VC
OnlyVideoPlayerView 동영상 재생이 이루어지는 레이어 포함하는 UIView
VideoPlayerControlView 동영상 컨트롤과 관련된 컴포넌트를 포함하는 UIView
ScreenSizeControlButton 화면 모드(기본, 전체화면)을 선택하는 버튼
PlayStatusControlButton 재생 모드(재생, 멈춤)를 선택하는 버튼

2. Scale 변환을 OnlyVideoPlayerView, VideoPlayerControlView 각각에 적용

func changeScreenSize(screenSizeStatus: ScreenSizeStatus) {
        switch screenSizeStatus {
        case .normal:
            self.videoPlayerView.layer.anchorPoint = CGPointMake(0.5, 0.5)
            self.videoPlayerControlView.layer.anchorPoint = CGPointMake(0.5, 0.5)
            UIView.animate(withDuration: 0.3, delay: TimeInterval(0.0), animations: { [self] in
                videoPlayerView.transform = CGAffineTransformTranslate(videoPlayerView.transform, 0, 0)
                videoPlayerView.transform = CGAffineTransform(rotationAngle: 0.0)
                videoPlayerView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.0, 1.0)
                
                videoPlayerControlView.transform = CGAffineTransformTranslate(videoPlayerControlView.transform, 0, 0)
                videoPlayerControlView.transform = CGAffineTransform(rotationAngle: 0.0)
                videoPlayerControlView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.0, 1.0)
                
                [videoPlayerControlView.playStatusControlButton, videoPlayerControlView.screenSizeControlButton].forEach({
                    $0.layer.anchorPoint = CGPoint(x: 0.5, y: 0.5)
                    $0.transform = CGAffineTransformScale($0.transform, 16.0/9.0, 1.0)
                })
                infoView.alpha = 1.0
            })
        case .full:
            UIView.animate(withDuration: 0.3, delay: TimeInterval(0.0), animations: { [self] in
                
                // NON PHYSICAL BUTTON
                self.videoPlayerView.layer.anchorPoint = CGPointMake(0.1, 0.5)
                
                // PHYSICAL BUTTON
                //self.videoPlayerView.layer.anchorPoint = CGPointMake(0.188, 0.5)
                
                videoPlayerView.transform = CGAffineTransform(rotationAngle: .pi/2.0)
                videoPlayerView.transform = CGAffineTransformScale(videoPlayerView.transform, 16.0/9.0, 16.0/9.0)
                
                // NON PHYSICAL BUTTON
                self.videoPlayerControlView.layer.anchorPoint = CGPointMake(0.235, -5.0)
                
                // PHYSICAL BUTTON
                //self.videoPlayerControlView.layer.anchorPoint = CGPointMake(0.3225, -5.0)
                videoPlayerControlView.transform = CGAffineTransform(rotationAngle: .pi/2.0)
                videoPlayerControlView.transform = CGAffineTransformScale(videoPlayerControlView.transform, 16.0/9.0, 1.0)
                
                videoPlayerControlView.playStatusControlButton.layer.anchorPoint = CGPoint(x: 0.8, y: 0.5)
                videoPlayerControlView.screenSizeControlButton.layer.anchorPoint = CGPoint(x: 0.2, y: 0.5)
                [videoPlayerControlView.playStatusControlButton, videoPlayerControlView.screenSizeControlButton].forEach({
                    $0.transform = CGAffineTransformScale($0.transform, 9.0/16.0, 1.0)
                })
                
                infoView.alpha = 0.0
            })
        }
    }
  • 물리 홈 버튼이 있는 기종 & 없는 기종에 따라 anchorPoint를 별개의 값으로 줘야 한다고?
  • 근데 또 CGFloat 값도 0.2, 0.1, 0.05 단위도 아니고 0.000... 이하 단위라고??
  • 0.3225??? 이 무슨 괴랄한...???

결론

  • VideoPlayerControlView의 Scale 관련 이슈는 해결했지만, 여전히 Orientation 관련해서는 해결하지 못한 상태로 남음
    -> 그리고 여기서 문득 뇌리를 스치는 PikiPick...Orientation...Constraints Update...
@jeong-hyeonHwang jeong-hyeonHwang added the documentation Improvements or additions to documentation label Feb 2, 2023
@jeong-hyeonHwang jeong-hyeonHwang self-assigned this Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant