分享意向不上传视频到YouTube工作 [英] Share Intent does not work for uploading video to youtube

查看:223
本文介绍了分享意向不上传视频到YouTube工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想分享正在创建并存储在SD卡外已获得其路径的视频。

<$p$p><$c$c>Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES).getAbsolutePath()

我使用SEND_INTENT如下:

 `意图shareIntent =新意图(Intent.ACTION_SEND);
   shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
   shareIntent.setType(视频/ MP4);
   shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,我的主题);
   shareIntent.putExtra(android.content.Intent.EXTRA_TEXT,我的文字);
   shareIntent.putExtra(Intent.EXTRA_STREAM,Uri.parse(video_path));
   startActivityForResult(Intent.createChooser(shareIntent,分享你的视频),SHARE_INTENT);`

问题:
虽然我通过Gmail分享,它让我撰写窗口附带视频。但该影片中没有大小,当你发送或取消该窗口,Gmail将与ContentResolver的InputStream的NPE崩溃。

在YouTube上的情况下,它说,你不能从云服务上传视频,我的视频清楚地驻留在设备上。

在Facebook的情况下,它被丢弃。这能与日wassup。 : - )

任何想法如何得到这个工作?

编辑:

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

更新

通过添加的file:/// 后缀,Gmail和Facebook的工作正常。
YouTube是抄袭还是关于视频无法从云服务上传。


解决方案

原因的Youtube失败等人的作品,是因为它会检查,看它是否是一个媒体文件。它仅认为它是一个媒体文件,如果它已被扫描。运行下面的code和它应该工作。它也将在画廊中显示。如何上传一个临时文件,我不知道。

 无效publishScan(){    // mVidFnam:/mnt/sdcard/DCIM/foo/vid_20131001_123738.3gp(或)
    MediaScannerConnection.scanFile(这一点,新的String [] {} mVidFnam,空,
            新MediaScannerConnection.OnScanCompletedListener(){
                公共无效onScanCompleted(字符串路径,开放的URI){
                    Log.d(TAGonScanCompleted URI+ URI);
                }
            });
}

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()

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);`

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.

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

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

Any ideas how to get this to work?

EDIT:

Video Path: /storage/emulated/0/Movies/MyFolder/my-video_1378253389208.mp4

UPDATE

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);


                }
            });
}

这篇关于分享意向不上传视频到YouTube工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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