MediaPlayer getVideoWidth - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for MediaPlayer getVideoWidth method.

This code example shows how to use the following methods: getDuration, getVideoHeight, getVideoWidth, prepare, setDataSource
     * @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;
    } 
 
Full Snippet Info
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getDuration, getVideoHeight, getVideoWidth, prepare, setDataSource
     * @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;
    } 
 
Full Snippet Info
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getVideoHeight, getVideoWidth, start
    	} catch (Exception e) {
        } 
    } 
     
    public void onPrepared(MediaPlayer mediaplayer) {
        mVideoWidth = mMediaPlayer.getVideoWidth();
        mVideoHeight = mMediaPlayer.getVideoHeight();
        if (mVideoWidth != 0 && mVideoHeight != 0) {
            holder.setFixedSize(mVideoWidth, mVideoHeight);
            mMediaPlayer.start();
        } 
    } 
     
    public void onBufferingUpdate(MediaPlayer arg0, int percent) {
    } 
     
    public void onCompletion(MediaPlayer arg0) {
    } 
     
    public void surfaceCreated(SurfaceHolder holder) {
Full Snippet Info
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getVideoHeight, getVideoWidth, start
		return false; 
	} 
 
	public void onPrepared(MediaPlayer mp) {
		Log.v(LOGTAG, "onPrepared Called");
		videoWidth = mp.getVideoWidth();
		videoHeight = mp.getVideoHeight();
 
		if (videoWidth > currentDisplay.getWidth()
				|| videoHeight > currentDisplay.getHeight()) {
			float heightRatio = (float) videoHeight
					/ (float) currentDisplay.getHeight();
			float widthRatio = (float) videoWidth
					/ (float) currentDisplay.getWidth();
 
			if (heightRatio > 1 || widthRatio > 1) {
				if (heightRatio > widthRatio) {
					videoHeight = (int) Math.ceil((float) videoHeight
							/ (float) heightRatio);
					videoWidth = (int) Math.ceil((float) videoWidth

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getDuration, getVideoHeight, getVideoWidth, prepare, setDataSource
     * @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;
    } 
 
Full Snippet Info
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getVideoHeight, getVideoWidth
	} 
 
	public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
		Log.v(LOGTAG, "onVideoSizeChanged Called");
 
		videoWidth = mp.getVideoWidth();
		videoHeight = mp.getVideoHeight();
 
		Log.v(LOGTAG, "Width: " + videoWidth);
		Log.v(LOGTAG, "Height: " + videoHeight);
 
		if (videoWidth > currentDisplay.getWidth()
				|| videoHeight > currentDisplay.getHeight()) {
			float heightRatio = (float) videoHeight
					/ (float) currentDisplay.getHeight();
			float widthRatio = (float) videoWidth
					/ (float) currentDisplay.getWidth();
 
			if (heightRatio > 1 || widthRatio > 1) {
				if (heightRatio > widthRatio) {
Full Snippet Info
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getVideoHeight, getVideoWidth
    } 
 
    MediaPlayer.OnVideoSizeChangedListener mSizeChangedListener =
        new MediaPlayer.OnVideoSizeChangedListener() { 
            public void onVideoSizeChanged(MediaPlayer mp, int width, int height) { 
                mVideoWidth = mp.getVideoWidth(); 
                mVideoHeight = mp.getVideoHeight(); 
                if (mVideoWidth != 0 && mVideoHeight != 0) { 
                    getHolder().setFixedSize(mVideoWidth, mVideoHeight); 
                } 
                if (mOnVideoSizeChangedListener != null) 
                    mOnVideoSizeChangedListener.onVideoSizeChanged(mp, width, height); 
            } 
    }; 
 
	MediaPlayer.OnInfoListener mInfoListener = new MediaPlayer.OnInfoListener() {
		public boolean onInfo(MediaPlayer mp, int what, int extra) { 
			if (what == MediaPlayer.MEDIA_INFO_NOT_SEEKABLE) 
			{ 
				mCanSeekBack = false; 
Full Snippet Info
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getDuration, getVideoHeight, getVideoWidth, prepare, setDataSource
     * @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;
    } 
Full Snippet Info
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getVideoHeight, getVideoWidth
		int width = video.getWidth();
		int height = video.getHeight();
		float boxWidth = width;
		float boxHeight = height;
 
		float videoWidth = mMediaPlayer.getVideoWidth();
		float videoHeight = mMediaPlayer.getVideoHeight();
 
		float wr = boxWidth / videoWidth;
		float hr = boxHeight / videoHeight;
		float ar = videoWidth / videoHeight;
 
		if (wr > hr)
		    width = (int) (boxHeight * ar);
		else 
		    height = (int) (boxWidth / ar);
		 
		holder.setFixedSize(width, height);
	} 
	 
Full Snippet Info
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getVideoHeight, getVideoWidth
    } 
 
    public List<Integer> getMovieInfo() {
        List<Integer> myResult = new ArrayList<Integer>();
        myResult.add(_myTextureId[0]);
        myResult.add(_myMediaPlayer.getVideoWidth());
        myResult.add(_myMediaPlayer.getVideoHeight());
        return myResult;
    } 
 
    public boolean isPlaying() { 
        if (_myMediaPlayer != null) {
            return _myMediaPlayer.isPlaying();
        } else { 
            return false; 
        } 
    } 
 
    public void setVolume(float theVolume) {
        _myMediaPlayer.setVolume(theVolume, theVolume);
Full Snippet Info
5
CodeRank
Experience pair programming with AI  Get Codota for Java

Related MediaPlayer getVideoWidth Questions & Answers:

getVideoWidth Method Overview
Returns the width of the video.
See Code Examples for other Android MediaPlayer Methods: