Example usage for android.media MediaPlayer getVideoWidth

List of usage examples for android.media MediaPlayer getVideoWidth

Introduction

In this page you can find the example usage for android.media MediaPlayer getVideoWidth.

Prototype

public native int getVideoWidth();

Source Link

Document

Returns the width of the video.

Usage

From source file:com.phonegap.Capture.java

/**
 * Get the Image specific attributes//w  ww .j  a  va  2 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/*from  w w w . ja  v  a 2s.com*/
 *
 * @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  .ja va  2s  .c o  m
 *
 * @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 w w w.  j  av a2  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;//w w  w  . j  av a 2  s  . c o  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;
}