如何在Instagram故事中同时分享一个视频作为背景和一张图片作为贴图?
如果这两个内容都是图片,则本说明书只有一个解决方案。
https://developers.facebook.com/docs/instagram/sharing-to-stories/
我想发送一个背景视频和一个贴图图片。 在Instagram故事中是否可能实现?
我尝试过,但很遗憾没有成功:
// Define image asset URI and attribution link URL
Uri backgroundAssetUri = Uri.fromFile(new File(backgroundPath));
Uri stickerAssetUri = Uri.fromFile(new File(stickerPath));
// Instantiate implicit intent with ADD_TO_STORY action,
// background asset, and attribution link
Intent intent = new Intent("com.instagram.share.ADD_TO_STORY");
intent.setDataAndType(backgroundAssetUri, "*/*");
intent.putExtra("interactive_asset_uri", stickerAssetUri);
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
callbackManager.startActivityForResult(Intent.createChooser(intent, "Share"), NatShareCallbacks.ACTIVITY_SHARE_INSTAGRAM_STORY);
但是两张图片的示例可以正常工作。我主要认为问题出在SetType上,因为它们是两种不同的内容类型。
[编辑]
仅具有标签而没有贴纸的视频已经在我的Android设备上工作过了,文档中的图像背景和图像贴纸示例也完美地工作。但是视频和贴纸一起使用就无法正常工作。
在iOS下,它可以毫无问题地运行:
NSData *backgroundVideo = [[NSFileManager defaultManager] contentsAtPath:path];
UIImage *appIcon = [UIImage imageNamed: [[[[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIcons"] objectForKey:@"CFBundlePrimaryIcon"] objectForKey:@"CFBundleIconFiles"] objectAtIndex:0]];
// Verify app can open custom URL scheme, open
NSURL *urlScheme = [NSURL URLWithString:@"instagram-stories://share"];
if ([[UIApplication sharedApplication] canOpenURL:urlScheme]) {
// Assign background image asset and attribution link URL to pasteboard
//NSArray *pasteboardItems = @[@{@"com.instagram.sharedSticker.backgroundVideo" : backgroundVideo}];
NSArray *pasteboardItems = @[@{@"com.instagram.sharedSticker.backgroundVideo" : backgroundVideo, @"com.instagram.sharedSticker.stickerImage" : UIImagePNGRepresentation(appIcon)}];
NSDictionary *pasteboardOptions = @{UIPasteboardOptionExpirationDate : [[NSDate date] dateByAddingTimeInterval:60 * 5]};
// This call is iOS 10+, can use 'setItems' depending on what versions you support
[[UIPasteboard generalPasteboard] setItems:pasteboardItems options:pasteboardOptions]; [[UIApplication sharedApplication] openURL:urlScheme options:@{} completionHandler:nil];
} else {
// Handle older app versions or app not installed case
}