如何将视频上传至YouTube的Android? [英] How to upload video to youtube in android?
本文介绍了如何将视频上传至YouTube的Android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在创建,记录在YouTube和其他社交网站的视频,并上传其应用程序。
有关上传我用的Droid共享功能和它的作品好。
在电子邮件,脸谱,Skype公司等上传作品完美的,但是当我选择的YouTube,它不上传我的视频。
下面是code我使用视频共享。
意图sharingIntent =新的意图(android.content.Intent.ACTION_SEND);
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECTSUBJECT_NAME);
sharingIntent.setType(视频/ *);
文件NEWFILE =新的文件(video_path);
sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM,Uri.fromFile(NEWFILE));
startActivity(Intent.createChooser(sharingIntent,)如果你想分享?);
解决方案
试试这个code。
ContentValues内容=新ContentValues(4);
content.put(Video.VideoColumns.DATE_ADDED,
System.currentTimeMillis的()/ 1000);
content.put(Video.Media.MIME_TYPE,视频/ MP4);
content.put(MediaStore.Video.Media.DATAvideo_path);
ContentResolver的解析器= getBaseContext()getContentResolver()。
开放的我们的uri = resolver.insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,内容);
意图sharingIntent =新的意图(android.content.Intent.ACTION_SEND);
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,标题);
sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM,URI);
startActivity(Intent.createChooser(sharingIntent,共享));
这code是的添加的在分享按钮的onClick() 方法的和得到的结果。 通过在 EXTRA_STREAM 作为一个 URI 不是文件中的值。
I am Creating an application which records video and uploads it on YouTube and others Social sites.
For upload I use Droid share functionality and it works good.
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?"));
解决方案
Try this code.
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:"));
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.
这篇关于如何将视频上传至YouTube的Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文