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

func tracks(withMediaType mediaType: AVMediaType) -> [AVAssetTrack] 接口在iOS 18 卡顿 #967

Open
fenglh opened this issue Jan 13, 2025 · 0 comments

Comments

@fenglh
Copy link

fenglh commented Jan 13, 2025

tracks(withMediaType mediaType: AVMediaType) 函数卡顿。(iOS15后不建议已使用)

func tracks(withMediaType mediaType: AVMediaType) -> [AVAssetTrack]

Description and Steps

  1. 预览视频的时候,会用到ZLNetVideoPreviewCell 。

Info

pod 'ZLPhotoBrowser', '4.5.6'
Xcode Version 15.4 (15F31d)
Device: e.g. iPhone 13 Pro Max
Device version: e.g. iOS 18.1

Configuration code of ZLPhotoConfiguration

item.asset.tracks(withMediaType: .video).first 这个代码卡顿。

 private func calculatePlayerFrame(for item: AVPlayerItem) -> CGRect {
     if let videoTrack = item.asset.tracks(withMediaType: .video).first {
         let size = videoTrack.naturalSize.applying(videoTrack.preferredTransform)
         let videoWHRatio = size.width / size.height
         let cellWHRatio = zl.width / zl.height
         
         let videoRect: CGRect
         if videoWHRatio > cellWHRatio {
             let videoH = zl.width / videoWHRatio
             videoRect = CGRect(x: 0, y: (zl.height - videoH) / 2, width: zl.width, height: videoH)
         } else {
             let videoW = zl.height * videoWHRatio
             videoRect = CGRect(x: (zl.width - videoW) / 2, y: 0, width: videoW, height: zl.height)
         }
         
         return videoRect
     } else {
         return bounds
     }
 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants