How to upload video to youtube in android?

后端 未结 8 1339
栀梦
栀梦 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:58

    This code is working for me fine.

    I try to Implement and get best result.

    so,if anyone face this type of problem try this code.

    I'm sure It's also works perfect for you.

    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, "path_of_video");
    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_text");
    //sharingIntent.setType("video/*");
    //File newFile = new File(path_var);
    sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM,uri);
    startActivity(Intent.createChooser(sharingIntent,"Where you want to share?")); 
    

    this code is pitting in your share button's onClick() method and get result.

提交回复
热议问题