How to hide system controls on AVPictureInPictureController's float window?

2.1k Views Asked by At

I want to hide these system controls on the iOS14 pip:

enter image description here

Any way I can do it?

3

There are 3 best solutions below

1
On BEST ANSWER

You can do it with KVC:

1. Hide forward button and back button:

Swift:

pipController.setValue(1, forKey: "requiresLinearPlayback")

Objective-C:

[self.pipController setValue:[NSNumber numberWithInt:1] forKey:@"requiresLinearPlayback"]

2. Hide progress bar, play button, forward button and back button:

Swift:

pipController.setValue(1, forKey: "controlsStyle")

Objective-C:

[self.pipController setValue:[NSNumber numberWithInt:1] forKey:@"controlsStyle"];

3. Hide all the controls on the pip:

Note: iOS16+ only

Swift:

pipController.setValue(2, forKey: "controlsStyle")

Objective-C:

[self.pipController setValue:[NSNumber numberWithInt:2] forKey:@"controlsStyle"];

For more detail about custom picture-in-picture, you can take a look at my repository here:

https://github.com/CaiWanFeng/PiP

0
On

You can hide at least the seek buttons via:

vc.requiresLinearPlayback = true

Where vc is your AVPictureInPictureController instance.

If you have already found a way how to hide the play button, please share it.

0
On
        if #available(iOS 14.0, *) {
            //Hide the seekbar
            pipController?.requiresLinearPlayback = true
        } else {
            // Fallback on earlier versions
        }
        
        //Hide the play/pause controls
        pipController?.setValue(1, forKey: "controlsStyle")