Share Intent无法将视频上传到YouTube

编程入门 行业动态 更新时间:2024-10-26 05:31:21
本文介绍了Share Intent无法将视频上传到YouTube的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试分享一个正在创建并存储在外部sdcard上的视频,该路径已经通过获取。

I am trying to share a video that is being created and stored on external sdcard whose path has been obtained by.

Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES).getAbsolutePath()

我正在使用SEND_INTENT如下: p>

I am using SEND_INTENT as follows:

Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); shareIntent.setType("video/mp4"); shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "My Subject"); shareIntent.putExtra(android.content.Intent.EXTRA_TEXT,"My Text"); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(video_path)); startActivityForResult(Intent.createChooser(shareIntent, "Share Your Video"),SHARE_INTENT);

问题:当我通过gmail分享它,它显示我附带视频的组合窗口。但是,视频没有显示大小,当您发送或取消窗口时,gmail将在内容分析器上与输入流NPE崩溃。

Problem: While I share through gmail, it shows me compose window with video attached. But no size being shown of the video and when you either send or cancel the window, gmail will crash with inputstream NPE on contentresolver.

如果是YouTube,它会显示您无法从云服务上传视频,我的视频清楚地存在于设备上。

In case of youtube, it says you cannot upload videos from cloud service, my video clearly resides on the device.

如果是Facebook,它将被无声地丢弃。这样做很好用wassup。 : - )

In case of facebook, it is silently discarded. This works fine with wassup. :-)

任何想法如何让这个工作?

Any ideas how to get this to work?

编辑:

视频路径: / storage / emulated / 0 /电影/ MyFolder / my-video_1378253389208.mp4

更新

由添加 file:/// 后缀,gmail和facebook工作正常。 Youtube仍然抱怨视频不能从云服务上传。

By adding file:/// suffix, gmail and facebook works fine. Youtube is still cribbing about "Videos cannot be uploaded from cloud services".

推荐答案

工作是因为它检查是否是媒体文件。它只是认为它是一个媒体文件,如果它已被扫描。运行下面的代码它应该工作。它也将在画廊中出现。如何上传临时文件我不知道。

The reason Youtube fails and others work is because it checks to see if it is a media file. It only thinks it is a media file if it has been scanned. Run the code below and it should work. It will also show up in the gallery. How to upload a temp file I do not know.

void publishScan() { //mVidFnam: "/mnt/sdcard/DCIM/foo/vid_20131001_123738.3gp" (or such) MediaScannerConnection.scanFile(this, new String[] { mVidFnam }, null, new MediaScannerConnection.OnScanCompletedListener() { public void onScanCompleted(String path, Uri uri) { Log.d(TAG, "onScanCompleted uri " + uri); } }); }

更多推荐

Share Intent无法将视频上传到YouTube

本文发布于:2023-11-17 07:37:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609325.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视频   Share   Intent   YouTube

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!