How to upload video to youtube in android?

后端 未结 8 1328
栀梦
栀梦 2020-12-08 05:27

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.

8条回答
  •  半阙折子戏
    2020-12-08 05:57

            ContentValues content = new ContentValues(4);
            content.put(MediaStore.Video.VideoColumns.DATE_ADDED,
                    System.currentTimeMillis() / 1000);
            content.put(MediaStore.Video.Media.MIME_TYPE, "video/mp4");
            content.put(MediaStore.Video.Media.DATA, path);
            ContentResolver resolver = getActivity().getContentResolver();
            Uri uri1 =  Uri.fromFile(new File(path)); 
    
            Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
            sharingIntent.setType("video/*");
            sharingIntent.setPackage("com.google.android.youtube");
            sharingIntent.putExtra(Intent.EXTRA_TITLE, "Title");
            sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Desc");
            sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM, uri1);
            startActivity(Intent.createChooser(sharingIntent, "Share to"));
    

提交回复
热议问题