List of usage examples for android.media MediaPlayer getVideoHeight
public native int getVideoHeight();
From source file:Main.java
public static boolean is3gpFileAudio(String url) { int height = 0; File mediaFile = new File(url); try {/*from ww w . j av a 2 s. co m*/ MediaPlayer mp = new MediaPlayer(); FileInputStream fs; FileDescriptor fd; fs = new FileInputStream(mediaFile); fd = fs.getFD(); mp.setDataSource(fd); mp.prepare(); height = mp.getVideoHeight(); mp.release(); } catch (Exception e) { Log.e("KKIM", "Exception trying to determine if 3gp file is video.", e); } Log.i("KKIM", "The height of the file is " + height); return height == 0; }
From source file:com.phonegap.Capture.java
/** * Get the Image specific attributes//w ww .j av a2 s.co m * * @param filePath path to the file * @param obj represents the Media File Data * @param video if true get video attributes as well * @return a JSONObject that represents the Media File Data * @throws JSONException */ private JSONObject getAudioVideoData(String filePath, JSONObject obj, boolean video) throws JSONException { MediaPlayer player = new MediaPlayer(); try { player.setDataSource(filePath); player.prepare(); obj.put("duration", player.getDuration()); if (video) { obj.put("height", player.getVideoHeight()); obj.put("width", player.getVideoWidth()); } } catch (IOException e) { Log.d(LOG_TAG, "Error: loading video file"); } return obj; }
From source file:org.apache.cordova.Capture.java
/** * Get the Image specific attributes/* w ww. j ava2 s . co m*/ * * @param filePath path to the file * @param obj represents the Media File Data * @param video if true get video attributes as well * @return a JSONObject that represents the Media File Data * @throws JSONException */ private JSONObject getAudioVideoData(String filePath, JSONObject obj, boolean video) throws JSONException { MediaPlayer player = new MediaPlayer(); try { player.setDataSource(filePath); player.prepare(); obj.put("duration", player.getDuration() / 1000); if (video) { obj.put("height", player.getVideoHeight()); obj.put("width", player.getVideoWidth()); } } catch (IOException e) { Log.d(LOG_TAG, "Error: loading video file"); } return obj; }
From source file:com.polyvi.xface.extension.capture.MediaType.java
/** * audio video .// w w w. j a va 2 s . com * * @param fileAbsPath ? * @param obj ? * @param isVideo ? video * @return ? JSONObject * @throws JSONException */ private JSONObject getAudioVideoData(String fileAbsPath, JSONObject obj, boolean isVideo) throws JSONException { MediaPlayer player = new MediaPlayer(); try { player.setDataSource(fileAbsPath); player.prepare(); obj.put(PROP_DURATION, player.getDuration() / XConstant.MILLISECONDS_PER_SECOND); if (isVideo) { obj.put(PROP_HEIGHT, player.getVideoHeight()); obj.put(PROP_WIDTH, player.getVideoWidth()); } } catch (IOException e) { XLog.e(CLASS_NAME, "Error: loading video file"); } player.release(); return obj; }
From source file:com.karura.framework.plugins.Capture.java
/** * Get the Image specific attributes/*from www.j a v a 2 s .c o m*/ * * @param filePath * path to the file * @param obj * represents the Media File Data * @param video * if true get video attributes as well * @return a JSONObject that represents the Media File Data * @throws JSONException */ private JSONObject getAudioVideoMetadata(String filePath, JSONObject obj, boolean video) throws JSONException { MediaPlayer player = new MediaPlayer(); try { player.setDataSource(filePath); player.prepare(); obj.put(DURATION_FIELD, player.getDuration()); if (video) { obj.put(HEIGHT_FIELD, player.getVideoHeight()); obj.put(WIDTH_FIELD, player.getVideoWidth()); } } catch (IOException e) { Log.d(LOG_TAG, "Error: loading video file"); } return obj; }
From source file:org.telegram.ui.ChatActivity.java
public void processSendingVideo(final String videoPath) { if (videoPath == null) { return;//from w w w . j a v a2 s .co m } Bitmap thumb = ThumbnailUtils.createVideoThumbnail(videoPath, MediaStore.Video.Thumbnails.MINI_KIND); TLRPC.PhotoSize size = FileLoader.scaleAndSaveImage(thumb, 90, 90, 55, currentEncryptedChat != null); if (size == null) { return; } size.type = "s"; TLRPC.TL_video video = new TLRPC.TL_video(); video.thumb = size; video.caption = ""; video.id = 0; video.path = videoPath; File temp = new File(videoPath); if (temp != null && temp.exists()) { video.size = (int) temp.length(); } UserConfig.lastLocalId--; UserConfig.saveConfig(false); MediaPlayer mp = MediaPlayer.create(ApplicationLoader.applicationContext, Uri.fromFile(new File(videoPath))); if (mp == null) { return; } video.duration = (int) Math.ceil(mp.getDuration() / 1000.0f); video.w = mp.getVideoWidth(); video.h = mp.getVideoHeight(); mp.release(); MediaStore.Video.Media media = new MediaStore.Video.Media(); MessagesController.Instance.sendMessage(video, dialog_id); if (chatListView != null) { chatListView.setSelection(messages.size() + 1); } scrollToTopOnResume = true; }