Disable AVPlayer dropdown on tvOS - ios

I want to add my own custom dropdown when a video is playing and the user swipes down. However, the default dropdown with asset info and audio settings always shows first when I swipe. I know I can get rid of it by making the video not be fullscreen, but then I would lose playback controls.
Any help would be greatly appreciated, thanks!
Update
let swipeDownGR = UISwipeGestureRecognizer(target: self, action: #selector(self.handleSwipes(sender:)))
swipeDownGR.direction = .down
view.addGestureRecognizer(swipeDownGR)
The default dropdown usually captures the gesture before my recognizer does.

I'm not too sure if you can get rid of some of the default behaviors that AVPlayerController provides. I actually would recommend creating your own custom playback controls (which isn't actually as hard as it sounds). All you have to do is to create a translucent UIView and overlay it on top of the AVPlayer, and add the elements that you want which gives you full control over the controls/elements that are there when the video is paused.

let vc: AVPlayerViewController = ... //your view controller
vc.playbackControlsIncludeInfoViews = false

Related

SCNAnimationPlayer to start playing animation on gesture

I am using Scenekit/ ARKit for the code and Blender for my 3D models. I have a 3D model with some keyframe animations - created in Blender, which has been exported easily into XCode. Nothing complicated - it's just a cat moving a bit up and then down.
I am using animation controls inside my tapGestureRecognizer. As soon as my view loads I have set the animation to be in paused state :-
nonGeometryObjectNode?.childNode(withName: "Armature", recursively: true)?.animationPlayer(forKey: "cat_animated-1")?.paused = true
Code for animation controls inside my tap gesture is as below.
let animationPlayer = hitResults.first?.node.parent?.childNode(withName: "Armature", recursively: true)?.animationPlayer(forKey: "cat_animated-1")
animationPlayer?.animation.autoreverses = true
animationPlayer?.animation.repeatCount = 1
animationPlayer?.animation.duration = 0.8
animationPlayer?.animation.blendInDuration = 0.2
animationPlayer?.animation.blendOutDuration = 0.2
animationPlayer?.paused = true
if (animationPlayer?.paused)! {
animationPlayer?.play()
}
It works fine, the only problem is it works just one time when tap is performed for the very first time. I tried using .paused, .stop() inside my tapGesture code, but animationPlayer doesn't replay as it should every time I am tapping on it. There is no bool var in SCNAnimationPlayer or else which I can use to detect if the animation has played itself out, so that I can use .stop() and then .play() again.
I did see two instance vars animationDidStart and animationDidStop which I thought probably would be useful to manage what I need. But I am at loss of ways to use these. What would be really helpful is what should be used to play and stop/ pause my animation whenever I tap on the object. Any pointer would be helpful.
I know it's an old question but in case anyone stumbles across it in future, the default action is for the animation to be removed once complete. Therefore to be able to play it again you need to set:
animationPlayer?.animation.isRemovedOnCompletion = false

Hiding AVPlayerController full screen button

I am loading my AVPlayerController on a specified UIView. Is there a way to hide only the fullscreen button shown on the AVPlayerController?
What you can do is hide all the controls using:
YourAVPlayerViewControllerName.showsPlaybackControls = false
and then create your own custom controls for the player
EDIT:
Also as mentioned in the comments, you cannot remove only one button, if you need the excat the same then you need to customise your view based on your requirment
I'm afraid you cant, but you can create a customized player using AVPlayerLayer then you can do almost anything you want in it but you need to handle everything manually, slider and playback Controls and so.
there are already lots of tutorials on how to achieve that like this one

How to handle next and previous button in the MPMoviePlayerViewController?

I am getting all events of the player by this notification MPMoviePlayerPlaybackStateDidChange, but not getting the next/previous event/action.
Can we handle all actions with the Now playing info in the background of application with this player?
Please let me know.
Thanks
MPMoviePlayerController, post only MPMoviePlayerPlaybackStateDidChangeNotification even when stop, previous and next buttons are clicked. You cannot find directly which button is clicked.
For this you can create your own custom control with custom button actions, from this you can detect easily which button is clicked.
NOTE: Before creating the custom control you must set the player's controlStyle property to MPMovieControlStyleNone to hide the default controls.

Receiving Gestures In an AVPlayer's Parent View

The long version: I am writing an app for iOS 8 in Swift, and its main functionality requires it to display a slideshow of sorts of pictures and videos. Considering that, to my knowledge, an AVPlayer cannot display pictures (I've tried feeding it an image URL in the same way I've fed it a video URL, and no luck), this requires me to add and remove a UIImageView or an AVPlayer from the view in order to display the appropriate content. However, in order to show the content correctly, I have to hide the app's navigationbar by default. The idea is to show it again if the user taps on the view. The view has a TapGestureRecognizer that serves this purpose. These tap gestures work correctly, assuming the view's content is the imageview. However, if the view presently contains the AVPlayer, the gestures are not received, rendering me unable to allow the user to show the navigationbar and leave the view. Here is how the AVPlayer is added to the view:
if (Utilities.IsVideo(url)) {
var escapedUrl = url.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)
let player = AVPlayer(URL: NSURL(string: escapedUrl!))
var cont = AVPlayerViewController()
cont.player = player
self.addChildViewController(cont)
self.view.addSubview(cont.view)
cont.view.frame = self.view.frame
player.play()
}
The short version: I have a view in an iOS app that contains a TapGestureRecognizer. The taps do not pass through an AVPlayer that is added to the view. How do I detect these taps?
It is worthy of mention that if the user taps on one of the media controls (such as the play button), the tap gesture is then recognized and its action triggered.

Remove the rotate icon in UIImagePickerController?

is it possible to remove the little rotate icon in the UIImagePickerController that switches between the front & back cameras? This is for an app that won't goto the Apple Store, and it's only on one device. Anything i can do? I see that i can do this, but it removes the record button as well.
cameraUI.showsCameraControls = NO;
Unfortunately not, there is no direct way to turn off 1 particular camera control.
What you could do, is to do the following:
// Create a view that recreates the camera control functions you need.
// Your view will need to be able to set the following properties on camera UI
// cameraCaptureMode, cameraFlashMode (NOT cameraDevice, which is the control you want to disappear)
UIView* customOverlay = [..way to create your custom overlay..];
cameraUI.showsCameraControls = NO;
cameraUI.cameraOverlayView = customOverlay;
If you need to know how to create a custom overlay, it may be worth raising as another question.
its all or nothing when it comes to showsCameraControls. You need to either set showsCameraControls to NO and create your own cameraOverlay view, or roll your own camera using AVFoundation where again you'd need to create your own camera controls.

Resources