From 210cc2bd5e8e0b5ceb360b4c10a46e96fd610ca8 Mon Sep 17 00:00:00 2001 From: macdonst Date: Fri, 3 Feb 2012 12:24:41 -0500 Subject: [PATCH] Fixing MediaFileData problem for MP4 video types Problem: Using Capture Video and mediaFile.getFormatData() on Android: Droid / 2.2.3: successfully get height, width, duration Samsung Galaxy Tab 10.1 / 3.1: recording appears to succeed, however height / width / duration all come back as 0. Fix: The Samsung Galaxy Tab 10.1 returns a MP4 video and not 3GPP as was expected in the Capture class. --- framework/src/org/apache/cordova/Capture.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/framework/src/org/apache/cordova/Capture.java b/framework/src/org/apache/cordova/Capture.java index d2d5b7d3..64a76f3c 100644 --- a/framework/src/org/apache/cordova/Capture.java +++ b/framework/src/org/apache/cordova/Capture.java @@ -42,6 +42,7 @@ import android.util.Log; public class Capture extends Plugin { private static final String VIDEO_3GPP = "video/3gpp"; + private static final String VIDEO_MP4 = "video/mp4"; private static final String AUDIO_3GPP = "audio/3gpp"; private static final String IMAGE_JPEG = "image/jpeg"; @@ -128,7 +129,7 @@ public class Capture extends Plugin { else if (mimeType.endsWith(AUDIO_3GPP)) { obj = getAudioVideoData(filePath, obj, false); } - else if (mimeType.equals(VIDEO_3GPP)) { + else if (mimeType.equals(VIDEO_3GPP) || mimeType.equals(VIDEO_MP4)) { obj = getAudioVideoData(filePath, obj, true); } } @@ -167,7 +168,7 @@ public class Capture extends Plugin { try { player.setDataSource(filePath); player.prepare(); - obj.put("duration", player.getDuration()); + obj.put("duration", player.getDuration()/1000); if (video) { obj.put("height", player.getVideoHeight()); obj.put("width", player.getVideoWidth());