After
If you set AvPlayerViewController.showsPlaybackControls on the wrong, the control will not be displayed at all. Even if you tap the screen.
I want to hide the control, but still be able to tap and call them. If I mentioned the property is set to the right, then they start visible. (Yes, they are faded after a few seconds). Is there a way to start hiding, but still accessible? Update: I'm making my own control for better optimization.
It's more difficult but it's worth the time. Please read Apple's sample code for reference. It is also about how to apply the RIP but also about creating custom controls:
UPDATE: When used, AVPlayerViewController only touchesBegan event activated, and event not touchesEnded. But enough to show the controls
You need to first hide the control. Right before you present this code to AVPlayerViewController
YourAVPlayerViewController.showsPlaybackControls = false
Then there is the AVPlayerViewController subclass and add this function:
< Pre> overhead function touchesBegan (touches: set , withEvent event: UIEvent) {self.showsPlaybackControls = true super.touchesBegan (touches, withEvent: event)}
< Older Solution: The main idea I have solved it now is that it does not need long time to put a UIView on top of AVPlayerViewController The variable is reveive, and that is to hide the UIView
Here is the code:. Import AVKit Import UIKit // Create a custom AVPlayerViewController @available (iOS 8.0, *) Ultimate Class CustomAVPlayerViewController: AVPlayerViewController {// All Lazy Tops Topview = UIView (to put on top of the frame)
Create a UIView for: CGRectMake (0, 0, width, height)) viewDidLoad () {super.viewDidLoad () // Override the function for sure, do not set clearcolor to // (alpha = 0, because this user interaction Will stop receiving) topView.backgroundColor = UIColor.clearColor (this set) // Add this to the view of AVPlayerViewController self.view.addSubview (Topview) // This brings self.view.bringSubviewToFront (Topview) in front // Add a tap gesture identifier topView.addGestureRecognizer (UITapGestureRecognizer (target: auto, action: "yes dleTap")) // tap function handleTap handle () {/ / = Controls self.showsPlaybackControls Show True // Topview Hide Later when necessary, you can see it self.topView.hidden = true}}And when you need to hide control, do this:
< Pre> on AVViewController = CustomAVPlayerViewController () ... // Hide Control AVViewController.showsPlaybackControls = false // Show Topview AVViewController.topView.hidden = false
No comments:
Post a Comment