简体   繁体   English

分享到 TikTok [视频套件] - Swift

[英]Share on TikTok [Video Kit] - Swift

Background: I am working on animated video making application.背景:我正在开发动画视频制作应用程序。 Once a user generate their video than we save that video inside their local storage.一旦用户生成他们的视频,我们就会将该视频保存在他们的本地存储中。 Now I want to provide new feature of sharing that video on TikTok.现在我想提供在 TikTok 上分享该视频的新功能。

For adding TikTok sharing feature I am following the TikTok SDK .为了添加 TikTok 共享功能,我正在关注TikTok SDK

Issue: According to this documentation, I have to implement the function that is taking asserts as parameters.问题:根据此文档,我必须实现将断言作为参数的 function。 I am having the url of video that is created by user.我有用户创建的视频 url。 How do I convert mp4 video or url into assets?如何将 mp4 视频或 url 转换为资产?

Code: Set share localIdentifiers as PHAsset.代码:将共享 localIdentifiers 设置为 PHAsset。

var mediaLocalIdentifiers: [String] = []

for asset in self.selectedAssets {

    mediaLocalIdentifiers.append(asset)

}

request.localIdentifiers = mediaLocalIdentifiers

Link to this function 链接到这个 function

Error:错误:

TikTokOpenSDKErrorCodeUserCanceled | TikTokOpenSDKErrorCodeUserCanceled | -2 | -2 | User Canceled share in TikTok.用户取消了在 TikTok 中的分享。 TikTokOpenSDKShareRespStateParamValidError| TikTokOpenSDKShareRespStateParamValidError| 20002 | 20002 | Params parsing error.参数解析错误。

Kindly help me with converting url into assets or if someone has applied TikTok sharing feature, please help me out.请帮助我将 url 转换为资产,或者如果有人应用了 TikTok 共享功能,请帮助我。

Once a user generate their video than we save that video inside their local storage一旦用户生成他们的视频,我们就会将该视频保存在他们的本地存储中

Well, there's your problem right there.嗯,你的问题就在那里。 The SDK function you have pointed to expects the video to be in the photos library, not in the user's local storage.您指出的SDK function期望视频在照片库中,而不是在用户的本地存储中。 That is what makes the video available through an asset (a PHAsset).这就是通过资产(PHAsset)使视频可用的原因。

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

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