将视频和贴纸图像分享到Android上的Instagram Story [英] Share video and sticker Image to Instagram Story on Android

查看:446
本文介绍了将视频和贴纸图像分享到Android上的Instagram Story的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何与Instagram故事一起共享视频作为背景和图像作为贴纸?

如果两个内容均为图像,则本文档仅提供一种解决方案.

This documentation has only one solution if both contents are images.

https://developers.facebook.com/docs/instagram/故事分享/

我想发送背景视频和贴纸图像. Instagram Story可以做到这一点吗?

I would like to send a background video together with a sticker image. Is that possible with Instagram Story?

我尝试过,但是不幸的是它没有用:

   // 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 看到了问题,因为它们是两种不同的内容类型.

But the example with two images works without problems. I see the problem mainly with SetType, because they are two different content types.

没有贴纸的单独视频已经可以在Android上使用,并且带有图像背景和图像贴纸的文档示例也可以完美运行.但是不能将视频和贴纸放在一起.

Video alone without stickers had already worked for me on Android and the example of the documentation with image-background and image-sticker also works perfectly. But not video and sticker together.

它可以在iOS上正常运行:

It works under iOS without any problems:

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

}

推荐答案

这是一个错误.

Facebook写道: 他们现在也已将功能添加到Android中,因此您现在应该可以发送带有标签的背景."

Facebook wrote: "They've added the functionality now to Android as well, so you should be able to send a background with a sticker now."

这篇关于将视频和贴纸图像分享到Android上的Instagram Story的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆