【发布时间】:2019-08-07 13:57:30
【问题描述】:
我使用nativescript-imagepicker-plugin 作为文件选择器。
这将返回一个PHAsset。
我必须将其复制到临时目录才能上传。
我是iOS新手,所以我尝试了一下:
const options = PHVideoRequestOptions.new();
options.version = PHVideoRequestOptionsVersion.Current;
PHImageManager
.defaultManager()
.requestAVAssetForVideoOptionsResultHandler(
phAsset
, options
, (avAsset, audioMix, info) => {
try {
const tempFilePath = path.join(tempFolderPath, `${Date.now()}.mp4`);
const targetURL = NSURL.fileURLWithPath(tempFilePath);
const exportSession = AVAssetExportSession.alloc(avAsset, AVAssetExportPresetPassthrough);
exportSession.outputUrl = targetURL;
exportSession.outputFileType = AVFileTypeMPEG4;
exportSession.exportAsynchronouslyWithCompletionHandler(() => {
console.log(exportSession.status);
});
}
catch (e) {
console.log(e);
}
}
);
我的代码崩溃没有错误,所以我不知道从哪里开始调试。 我想要一个 MP4,也可以在网络上显示。
最后我需要一个 mp4 文件的字符串(路径)来上传带有nativescript-background-http 的 ID。
【问题讨论】:
标签: javascript ios nativescript phasset avasset