2015-10-05 47 views
0

我想要的視頻上傳到WhatsappALAsset URL,,但它加載使用UIActivityViewController的WhatsApp不能從assetURL採摘視頻UIActivityViewController

ALAssetsLibrary *assetLibrary=[[ALAssetsLibrary alloc] init]; 

[assetLibrary assetForURL:self.videoURL resultBlock:^(ALAsset *asset) { 
    NSArray *objectsToShare = @[asset.defaultRepresentation.url]; 
    FrodoInstagramActivity *instagramActivity = [[FrodoInstagramActivity alloc] init]; 

    UIActivityViewController *activityVC = [[UIActivityViewController alloc] 
     initWithActivityItems:objectsToShare applicationActivities:@[instagramActivity]]; 
    [self presentViewController:activityVC animated:YES completion:nil]; 
} failureBlock:nil]; 
+0

爲什麼上傳URL,上傳資產本身。我認爲這可能會解決這個問題。 –

+0

@AlvinVarghese直接上傳資產會刪除acitvityController中除我的自定義活動以外的所有選項 –

+0

請問您是否可以將您的視頻資產轉換爲NSData並試試? –

回答

1

試試這個能劇,「電影時,我分享視頻「您從視頻資源保存到本地目錄的視頻。

NSString * savePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/whatsAppTmp.wam"]; 

savePath = [[NSBundle mainBundle] pathForResource:@"Movie" ofType:@"m4v"]; 


    _documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]]; 
    _documentInteractionController.UTI = @"net.whatsapp.movie"; 
    _documentInteractionController.delegate = (id)self; 

    [_documentInteractionController presentOpenInMenuFromRect:CGRectMake(0, 0, 0, 0) inView:self.view animated: YES]; 

將您的資產保存到本地,並獲取本地URL。在上面的代碼上傳遞URL路徑。讓我們來看看。

不要在每個視頻的本地創建每個文件,只需對所有視頻使用相同的文件名並替換視頻。並在成功上傳後從本地刪除視頻。 This might help

+0

我已經嘗試過,但在大文件的情況下創建臨時副本可能是一個問題。無論如何感謝 –

+0

WhatsApp沒有使用資產網址加載視頻。每個其他平臺都在做。仍然找出這個問題的實際解決方案。現在創建了一個whatsapp的自定義活動 –

+0

你試過這個_documentInteractionController代碼嗎? –

0

我也面臨這個問題與whatsapp共享鏈接。

在whatsapp共享重新分配給字符數。

請分享網址和文字,最多150個字符。

然後說出發生了什麼。

快樂編碼:)

+0

不,網址不超過150個字符。它是assets-library://asset/asset.mp4?id = 004BB7E9-6F9F-4C3A-8FAD-CAC26952708C&ext = mp4 –