Skip to content

Commit

Permalink
Work around bug in sdk 33 - this gets the Video working on that platform
Browse files Browse the repository at this point in the history
  • Loading branch information
stevehof committed Aug 31, 2023
1 parent bd55251 commit 210a124
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/android/Capture.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,16 @@ public void run() {
}
}).get(); // get() blocks the thread
LOG.d(LOG_TAG, "Taking a video and saving to: " + videoUri.toString());
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, videoUri);

intent.putExtra("android.intent.extra.durationLimit", req.duration);
intent.putExtra("android.intent.extra.videoQuality", req.quality);

if(Build.VERSION.SDK_INT != 33){
// There appears to be a bug in 33 that if we set these it doesn't call generateVideoValues()
// See https://android.googlesource.com/platform/packages/apps/Camera2/+/refs/heads/android13-release/src/com/android/camera/VideoModule.java
// VideoModule.java:1263
// java.lang.NullPointerException: Attempt to invoke virtual method 'void android.content.ContentValues.put(java.lang.String, java.lang.Long)' on a null object reference
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, videoUri);

intent.putExtra("android.intent.extra.durationLimit", req.duration);
intent.putExtra("android.intent.extra.videoQuality", req.quality);
}
this.cordova.startActivityForResult((CordovaPlugin) this, intent, req.requestCode);
} catch (InterruptedException e) {
pendingRequests.resolveWithFailure(req, createErrorObject(CANNOT_CREATE_TARGET_DIRECTORY, "Thread interrupted while creating path for new video"));
Expand Down Expand Up @@ -442,6 +447,9 @@ public void onImageActivityResult(Request req) {

public void onVideoActivityResult(Request req, Intent intent) {
try {
if(intent != null) {
videoUri = intent.getData();
}
if(videoUri == null){
File movie = new File(getTempDirectoryPath(), "Capture.avi");
videoUri = Uri.fromFile(movie);
Expand Down

0 comments on commit 210a124

Please sign in to comment.