如何在android中将视频上传到youtube? [英] How to upload video to youtube in android?

查看:37
本文介绍了如何在android中将视频上传到youtube?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个应用程序,用于录制视频并将其上传到 YouTube 和其他社交网站.

I am Creating an application which records video and uploads it on YouTube and others Social sites.

对于上传,我使用 Droid 共享功能,效果很好.

For upload I use Droid share functionality and it works good.

在电子邮件、Facebook、Skype 等上传工作完美,但当我选择 YouTube 时,它​​不上传我的视频.

In e-mail, Facebook, Skype, etc upload works perfect, but when I select YouTube, it does not upload my video.

这是我用于视频共享的代码.

Here is the code I use for video sharing.

Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"SUBJECT_NAME");
sharingIntent.setType("video/*");
File newFile = new File(video_path);
sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM,Uri.fromFile(newFile));
startActivity(Intent.createChooser(sharingIntent,"Where you want to share?"));

推荐答案

试试这个代码.

ContentValues content = new ContentValues(4);
content.put(Video.VideoColumns.DATE_ADDED,
System.currentTimeMillis() / 1000);
content.put(Video.Media.MIME_TYPE, "video/mp4");
content.put(MediaStore.Video.Media.DATA, "video_path");
ContentResolver resolver = getBaseContext().getContentResolver();
Uri uri = resolver.insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, content);

Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Title");
sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM,uri);
startActivity(Intent.createChooser(sharingIntent,"share:")); 

此代码添加到您的分享按钮的 onClick() 方法 并获得结果.将 EXTRA_STREAM 中的值作为 URI 而非文件传递.

this code is add in your share button's onClick() method and get result. pass the value in EXTRA_STREAM as an URI not as file.

这篇关于如何在android中将视频上传到youtube?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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