Record, save and play a video in Android

前端 未结 3 756
南方客
南方客 2021-02-06 09:36

I am trying to make an app that records a video using the camera app, and then saves that video on SD card so I can play it. I have some code but I\'m lost on how to continue as

3条回答
  •  粉色の甜心
    2021-02-06 09:54

    Well its very simple to record videos in android by using this simple code

    First on a button click simple start an Intent

    Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
                if (takeVideoIntent.resolveActivity(getPackageManager()) != null) {
                    startActivityForResult(takeVideoIntent,
                            CAMERA_REQUEST_CODE_VEDIO);
                }
    

    than onActivityResult method

    Uri videoUri = data.getData();
                    path = Utils.getRealPathFromURI(videoUri, this);
                    manageVideo(path);///What ever you want to do with your vedio
    

    and finally add permissions to the menifest

    
    

    Hope it help others who are looking for help :)

    Thanks

提交回复
热议问题