简体   繁体   English

快速在iOS上共享资产库视频

[英]Sharing asset library video on ios with swift

I save a video file to Library and then try to share the NSURL of the asset library with UIActivityViewController. 我将视频文件保存到Library,然后尝试与UIActivityViewController共享资产库的NSURL。

For some apps like viber it works, but some other like whatsapp and Gmail the URL is shared instead of video file itself. 对于某些应用程序(如viber),它可以工作,但对于其他某些应用程序(如whatsapp和Gmail),URL是共享的,而不是视频文件本身。

here is an example assets-library://asset/asset.mov?id=944F2398-FE49-44EA-9AF1-41EBC017EA64&ext=mov 这是一个示例assets-library://asset/asset.mov?id = 944F2398-FE49-44EA-9AF1-41EBC017EA64&ext = mov

any idea how to share the video file from library with Swift and UIActivityViewController ? 任何想法如何使用Swift和UIActivityViewController从库中共享视频文件?

let activityViewController : UIActivityViewController = UIActivityViewController(activityItems: [videoURL], applicationActivities: nil)
self.presentViewController(activityViewController, animated: true, completion: nil)

You need to provide the actual physical file path. 您需要提供实际的物理文件路径。 Example URL: 范例网址:

file:///var/mobile/Containers/Data/Application/path-to-my-videos-folder/my-video.mp4 文件:///var/mobile/Containers/Data/Application/path-to-my-videos-folder/my-video.mp4

One issue that I see happening with your journey is that the share dialog will have the option to save to library again, so feels like you're spinning in circle there. 我发现旅途中遇到的一个问题是,共享对话框将具有再次保存到库的选项,因此感觉就像在旋转。

I hope this helps. 我希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM