diff --git a/README.md b/README.md index e997e18..066ec88 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,37 @@ -[中文文档](README_cn.md) - +# [中文文档](README_cn.md) # Features: -1. You can add any custom view on the pip window; -2. You can hide speed button, backward button, play button and progress bar on the pip window; -3. You can modify the pip window’s shape dynamically with code; -4. You can rotate the pip window with code; -5. You can take photos and record a video while using pip; -6. The screen would not turn dark when you take photos or record videos; -7. Timer would never stop while taking photos or recording videos; -8. The timer's accuracy is millisecond; -9. The solution for your app rejected by Apple. +### 1. You can add any custom view on the pip window. + +```swift +func pictureInPictureControllerWillStartPictureInPicture(_ pictureInPictureController: AVPictureInPictureController) { + // note this is first window + if let window = UIApplication.shared.windows.first { + window.addSubview(customView) + // use autoLayout + customView.snp.makeConstraints { (make) -> Void in + make.edges.equalToSuperview() + } + } +} +``` + +### 2. You can hide speed button, backward button, play button and progress bar on the pip window. +https://stackoverflow.com/questions/67528832/how-to-hide-system-controls-on-avpictureinpicturecontrollers-float-window#67528832 + +### 3. You can modify the pip window’s shape dynamically with code. + +**The shape of the pip window depends on the shape of video**. So just change current video to a video with a different shape. + +Sample code like: + +```objective-c +NSURL *url = [[NSBundle mainBundle] URLForResource:videoName withExtension:@"MP4"]; +AVAsset *asset = [AVAsset assetWithURL:url]; +AVPlayerItem * item = [[AVPlayerItem alloc] initWithAsset:asset]; +[self.pipController.playerLayer.player replaceCurrentItemWithPlayerItem:item]; +``` # Demos: @@ -27,6 +47,6 @@ # Contact: -For more technical exchange you can add my WeChat: *cq1351675135* or scan: +For more technical exchange you can scan to add my WeChat: ![contact](contact.PNG)