Trouble with youtube upload

天大地大妈咪最大 提交于 2019-12-24 06:45:12

问题


I am trying to upload a video in youtube using intents.The problem is the video is not sharing in the youtube only working perfectly in gmail,blutooth etc,.. The code I am using is

        Log.d("Share Example", "Share button is clicked");
        String outputFile = pathOfSelected;
        Log.d("Share Example", "outputFileURL: " + outputFile);

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

        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("video/*");
        intent.putExtra(Intent.EXTRA_STREAM, uri);
        startActivity(Intent.createChooser(intent, "Share using"));

Somebody please help me to sort it out


回答1:


try this work for me

        Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);

        sharingIntent.setType("video/*");

        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, share_outputFileName);
    ContentResolver resolver = getBaseContext().getContentResolver();
        Uri uri = resolver.insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, content);


        sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"");
        sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT,getString("");
        sharingIntent.putExtra(android.content.Intent.EXTRA_TITLE,getString("");
        sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM,uri);


        startActivity(Intent.createChooser(sharingIntent,"Share video"));


来源:https://stackoverflow.com/questions/17037816/trouble-with-youtube-upload

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!