Skip to content

Commit

Permalink
[Video] Add dimension info to share intent pt.2 (#5640)
Browse files Browse the repository at this point in the history
  • Loading branch information
haileyok authored Oct 7, 2024
1 parent 509b37f commit 80e25b3
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions modules/Share-with-Bluesky/ShareViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,23 @@ class ShareViewController: UIViewController {
} catch {}
return nil
}

private func saveVideoWithInfo(_ dataUrl: URL) -> String? {
let ext = String(dataUrl.lastPathComponent.split(separator: ".").last ?? "mp4")
guard let tempUrl = getTempUrl(ext: ext),
let track = AVURLAsset(url: dataUrl).tracks(withMediaType: AVMediaType.video).first else {
guard let tempUrl = getTempUrl(ext: ext) else {
return nil
}
let size = track.naturalSize.applying(track.preferredTransform)


let data = try? Data(contentsOf: dataUrl)
try? data?.write(to: tempUrl)

return "\(tempUrl.absoluteString)|\(size.width)||\(size.height)"

guard let track = AVURLAsset(url: dataUrl).tracks(withMediaType: AVMediaType.video).first else {
_ = try? FileManager().removeItem(at: tempUrl)
return nil
}

let size = track.naturalSize.applying(track.preferredTransform)
return "\(tempUrl.absoluteString)|\(size.width)|\(size.height)"
}

private func completeRequest() {
Expand Down

0 comments on commit 80e25b3

Please sign in to comment.