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

Notch support #193

Open
patreu22 opened this issue Oct 12, 2018 · 1 comment
Open

Notch support #193

patreu22 opened this issue Oct 12, 2018 · 1 comment

Comments

@patreu22
Copy link

Hey there, any plans to adjust this player to support the iPhone X notch?

@rico237
Copy link

rico237 commented Mar 28, 2019

This is an old issue but for those who might see this later i maid the change in MobilePlayerControlsView.swift the function is override func layoutSubviews()

There is the code :

override func layoutSubviews() {
    let size = bounds.size
    
    var topSafeAreaHeight: CGFloat = 0
    var bottomSafeAreaHeight: CGFloat = 0
    
    if #available(iOS 11.0, *) {
        let window = UIApplication.shared.windows[0]
        let safeFrame = window.safeAreaLayoutGuide.layoutFrame
        topSafeAreaHeight = safeFrame.minY
        bottomSafeAreaHeight = window.frame.maxY - safeFrame.maxY
    }
    
    previewImageView.frame = bounds
    activityIndicatorView.sizeToFit()
    activityIndicatorView.frame.origin = CGPoint(
      x: (size.width - activityIndicatorView.frame.size.width) / 2,
      y: (size.height - activityIndicatorView.frame.size.height) / 2)
    topBar.sizeToFit()
    topBar.frame = CGRect(
      x: 0,
      y: controlsHidden ? -topBar.frame.size.height : topSafeAreaHeight,
      width: size.width,
      height: topBar.frame.size.height)
    topBar.alpha = controlsHidden ? 0 : 1
    bottomBar.sizeToFit()
    bottomBar.frame = CGRect(
      x: 0,
      y: size.height - (controlsHidden ? 0 : bottomBar.frame.size.height + bottomSafeAreaHeight),
      width: size.width,
      height: bottomBar.frame.size.height)
    bottomBar.alpha = controlsHidden ? 0 : 1
    overlayContainerView.frame = CGRect(
      x: 0,
      y: controlsHidden ? 0 : topBar.frame.size.height,
      width: size.width,
      height: size.height - (controlsHidden ? 0 : (topBar.frame.size.height + bottomBar.frame.size.height)))
    for overlay in overlayContainerView.subviews {
      overlay.frame = overlayContainerView.bounds
    }
    super.layoutSubviews()
  }
}

I will submit a pull request with that update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants