Share Intent无法将视频上传到YouTube [英] Share Intent does not work for uploading video to youtube

查看:264
本文介绍了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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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