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

How to correctly use YouTubePlayerViewController? #114

Open
nemecek-filip opened this issue Jan 3, 2025 · 1 comment
Open

How to correctly use YouTubePlayerViewController? #114

nemecek-filip opened this issue Jan 3, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@nemecek-filip
Copy link

Hello,

in my project I am mostly using YouTubePlayerView which works great, but for one use case I need the YouTubePlayerViewController. I essentially have just a button that should open fullscreen video.

When I create the YouTubePlayerViewController the usage example suggests, it goes inside the safe areas and there is no way to dismiss the controller for the user when I use the full screen presentation.

I thought maybe adding navigation controller is the expected approach, but that did not help either.

Is there something I am missing? Any help/pointers appreciated 🙏

PS: I am happy to use the SwiftUI player if that would work better for my full screen use case.

@SvenTiigi
Copy link
Owner

Hi @nemecek-filip,

please check out the develop branch which has an updated implementation of the YouTubePlayerViewController which respects the top safe area layout guide.

self.view.addSubview(self.player.webView)
self.player.webView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
self.player.webView.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor),
self.player.webView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
self.player.webView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor),
self.player.webView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor),
])

Be aware that the develop branch contains some breaking changes which will be released in the near future.

@SvenTiigi SvenTiigi added the bug Something isn't working label Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants