Android MediaStore insertVideo

后端 未结 5 684
予麋鹿
予麋鹿 2020-11-30 09:46

So our app has the option to take either a picture or a video. If the user takes a picture, we can use the MediaStore.Images.Media.insertImage function to add the new image

5条回答
  •  离开以前
    2020-11-30 09:50

    If your app is generating a new video and you simply want to give the MediaStore some metadata for it, you can build on this function:

    public Uri addVideo(File videoFile) {
        ContentValues values = new ContentValues(3);
        values.put(MediaStore.Video.Media.TITLE, "My video title");
        values.put(MediaStore.Video.Media.MIME_TYPE, "video/mp4");
        values.put(MediaStore.Video.Media.DATA, videoFile.getAbsolutePath());
        return getContentResolver().insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, values);
    }
    

    EDIT: As of Android 4.4 (KitKat), this method no longer works.

提交回复
热议问题