android - Video capturing in nougat? -


i create video capturing app in nougat supported capturing video , video capture , save default camera folder result code -1. using following code.

public void startrecordingvideo() {     if (getpackagemanager().hassystemfeature(packagemanager.feature_camera_front)) {         intent intent = new intent(mediastore.action_video_capture);         file mediafile = new file(                 environment.getexternalstoragedirectory().getabsolutepath() + "/myvideo.mp4");         videouri = uri.fromfile(mediafile);         //intent.putextra(mediastore.extra_output, videouri);         startactivityforresult(intent, video_capture);     } else {         toast.maketext(this, "no camera on device", toast.length_long).show();     } } 

i putting onactivityresult code here

if (requestcode == video_capture) {             //if (resultcode == result_ok) {                 int width = 0, displaywidth = 0;                 //int height = 0, displayheight = 0;                 if (new file(constants.app_path + "/myvideo1.mp4").exists()) {                     mediametadataretriever retriever = new mediametadataretriever();                     retriever.setdatasource(constants.app_path + "/myvideo1.mp4");                     bitmap bmp = retriever.getframeattime();                     width = bmp.getheight();                      videopath = constants.app_path + "/myvideo1.mp4";                     displaymetrics displaymetrics = new displaymetrics();                     mainactivity.this.getwindowmanager().getdefaultdisplay().getmetrics(displaymetrics);                     displaywidth = displaymetrics.widthpixels;                     string time = retriever.extractmetadata(mediametadataretriever.metadata_key_duration);                     int videoduration = integer.parseint(time);                     if (width >= displaywidth * 1.5 && videoduration <= constants.video_upper_limit) {                         new resizevideotask(videopath).execute();                     } else if (videoduration > constants.video_upper_limit) {                         showtimedialog();                     } else {                         file afile = new file(videopath);                         string path = constants.app_path + "/myvideo.mp4";                         file destfile = new file(path);                         if (destfile.exists()) {                             destfile.delete();                         }                         copyfile(new fileinputstream(afile),new fileoutputstream(destfile));                         intent switchintent = new intent(mainactivity.this,videoactivity.class);                         switchintent.putextra("uri", uri.fromfile(destfile).tostring());                         switchintent.putextra("file_path", path);                         startactivity(switchintent);                     }                     retriever.release();                 }             } else if (resultcode == result_canceled) {              } else {              //}         } 

first, did not pass extra_output in action_video_capture intent. result, camera app choose store video, , return uri via intent delivered onactivityresult(). not using that.

second, if uncomment intent.putextra(mediastore.extra_output, videouri); line (to fix problem preceding paragraph), videouri using here defined differently using in onactivityresult().


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -