我将使用AVCaptureMovieFileOutput
录制的mp4文件附加到UNNotificationServiceExtension
的通知中
显然,视频帧是上下颠倒的,并且在元数据中指定了方向
如果我在通知中打开视频,则可以正常播放,但预览是颠倒的
我尝试像这样指定裁剪矩形
do {
let upsideDown = CGRect(origin: CGPoint(x: 0, y: 1), size: CGSize(width: 1, height: -1))
try bestAttemptContent.attachments = [UNNotificationAttachment(
identifier: UUID().uuidString,
url: localurl!,
options: [
UNNotificationAttachmentOptionsTypeHintKey: kUTTypeMPEG4,
UNNotificationAttachmentOptionsThumbnailClippingRectKey: upsideDown.dictionaryRepresentation,
UNNotificationAttachmentOptionsThumbnailTimeKey: NSNumber(5.0)
]
)]
} catch {
print(error)
}
但是此代码根本不显示预览(但是视频仍然可以正常播放)