将视频和贴纸图像分享到Android上的Instagram Story

将视频和贴纸图像分享到Android上的Instagram Story,第1张

概述如何将视频作为背景和图像作为贴纸共享到InstagramStory?如果两个内容均为图像,则本文档仅提供一种解决方案.https://developers.facebook.com/docs/instagram/sharing-to-stories/我想发送背景视频和贴纸图像.InstagramStory可以做到吗?我尝试过,但是不幸的是它没有用://

如何将视频作为背景和图像作为贴纸共享到Instagram Story?

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

https://developers.facebook.com/docs/instagram/sharing-to-stories/

我想发送背景视频和贴纸图像. 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的问题,因为它们是两种不同的内容类型.

[编辑]

仅视频不带贴纸的视频已经可以在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, openNSURL *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}

解决方法:

立即检查的最明显的事情是:

>您的资产是否符合以下条件:

Uri to an image asset (JPG, PNG) or vIDeo asset (H.264, H.265, WebM).
Minimum dimensions 720×1280. Recommended image ratios 9:16 or 9:18.
VIDeos can be 1080p and up to 20 seconds in duration. The Uri needs to
be a content Uri to a local file on the device.

> intent.setDataAndType(backgroundAssetUri,“ * / *”); -文档说该函数的第二个值可以为null,但是我认为“ * / *”不是有效的mime类型:尝试使用MEDIA_TYPE_VIDEO-Link to Docs intent.setDataAndType(backgroundAssetUri,MEDIA_TYPE_VIDEO);

MEDIA_TYPE_VIDEO added in API level 11

public static final int MEDIA_TYPE_VIDEO

Constant for the MEDIA_TYPE column indicating that file is a vIDeo
file.

Constant Value: 3 (0x00000003)

>最后-您是否像示例中那样测试了启动活动:

    Activity activity = getActivity();    activity.grantUriPermission("com.instagram.androID", stickerAssetUri, Intent.FLAG_GRANT_READ_URI_PERMISSION);    if (activity.getPackageManager().resolveActivity(intent, 0) != null) {        activity.startActivityForResult(intent, 0);    }
总结

以上是内存溢出为你收集整理的将视频和贴纸图像分享到Android上的Instagram Story全部内容,希望文章能够帮你解决将视频和贴纸图像分享到Android上的Instagram Story所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1094952.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存