我正在尝试录制视频,然后在完成后将其上传到服务器。相关代码在这里:
public void recordVideo(View view){
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(takeVideoIntent, VIDEO_RESULT);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == VIDEO_RESULT){
handleCameraVideo(data);
}
}
private void handleCameraVideo(Intent intent) {
Uri mVideoUri = intent.getData();
File vidFile = new File(mVideoUri.getPath());
RequestParams params = new RequestParams();
try{
params.put("video", vidFile);
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
//finish upload here, this part isn't relevant to my question
}
问题是在我的try
块中抛出了 FileNotFoundException,并且堆栈跟踪打印出来。似乎我应该得到正确的文件:我从 Android 开发者网站获得了大部分代码,直到我制作文件的部分,所以它应该可以工作——这让我相信问题出在File vidFile = new File(mVideoUri.getPath());
线。任何帮助,将不胜感激。