当前位置: 首页>>代码示例>>Java>>正文


Java ScreenResolution.getResolution方法代码示例

本文整理汇总了Java中io.vov.vitamio.utils.ScreenResolution.getResolution方法的典型用法代码示例。如果您正苦于以下问题:Java ScreenResolution.getResolution方法的具体用法?Java ScreenResolution.getResolution怎么用?Java ScreenResolution.getResolution使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.vov.vitamio.utils.ScreenResolution的用法示例。


在下文中一共展示了ScreenResolution.getResolution方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setVideoLayout

import io.vov.vitamio.utils.ScreenResolution; //导入方法依赖的package包/类
/**
 * Set the display options
 *
 * @param layout      <ul>
 *                    <li>{@link #VIDEO_LAYOUT_ORIGIN}
 *                    <li>{@link #VIDEO_LAYOUT_SCALE}
 *                    <li>{@link #VIDEO_LAYOUT_STRETCH}
 *                    <li>{@link #VIDEO_LAYOUT_ZOOM}
 *                    </ul>
 * @param aspectRatio video aspect ratio, will audo detect if 0.
 */
public void setVideoLayout(int layout, float aspectRatio) {
  LayoutParams lp = getLayoutParams();
  Pair<Integer, Integer> res = ScreenResolution.getResolution(mContext);
  int windowWidth = res.first.intValue(), windowHeight = res.second.intValue();
  float windowRatio = windowWidth / (float) windowHeight;
  float videoRatio = aspectRatio <= 0.01f ? mVideoAspectRatio : aspectRatio;
  mSurfaceHeight = mVideoHeight;
  mSurfaceWidth = mVideoWidth;
  if (VIDEO_LAYOUT_ORIGIN == layout && mSurfaceWidth < windowWidth && mSurfaceHeight < windowHeight) {
    lp.width = (int) (mSurfaceHeight * videoRatio);
    lp.height = mSurfaceHeight;
  } else if (layout == VIDEO_LAYOUT_ZOOM) {
    lp.width = windowRatio > videoRatio ? windowWidth : (int) (videoRatio * windowHeight);
    lp.height = windowRatio < videoRatio ? windowHeight : (int) (windowWidth / videoRatio);
  } else {
    boolean full = layout == VIDEO_LAYOUT_STRETCH;
    lp.width = (full || windowRatio < videoRatio) ? windowWidth : (int) (videoRatio * windowHeight);
    lp.height = (full || windowRatio > videoRatio) ? windowHeight : (int) (windowWidth / videoRatio);
  }
  setLayoutParams(lp);
  getHolder().setFixedSize(mSurfaceWidth, mSurfaceHeight);
  Log.d("VIDEO: %dx%dx%f, Surface: %dx%d, LP: %dx%d, Window: %dx%dx%f", mVideoWidth, mVideoHeight, mVideoAspectRatio, mSurfaceWidth, mSurfaceHeight, lp.width, lp.height, windowWidth, windowHeight, windowRatio);
  mVideoLayout = layout;
  mAspectRatio = aspectRatio;
}
 
开发者ID:AJRdev,项目名称:ARDrone-Android-GEII,代码行数:37,代码来源:VideoView.java

示例2: setVideoLayout

import io.vov.vitamio.utils.ScreenResolution; //导入方法依赖的package包/类
/**
 * Set the display options
 *
 * @param layout      <ul>
 *                    <li>{@link #VIDEO_LAYOUT_ORIGIN}
 *                    <li>{@link #VIDEO_LAYOUT_SCALE}
 *                    <li>{@link #VIDEO_LAYOUT_STRETCH}
 *                    <li>{@link #VIDEO_LAYOUT_FIT_PARENT}
 *                    <li>{@link #VIDEO_LAYOUT_ZOOM}
 *                    </ul>
 * @param aspectRatio video aspect ratio, will audo detect if 0.
 */
public void setVideoLayout(int layout, float aspectRatio) {
	LayoutParams lp = getLayoutParams();
	Pair<Integer, Integer> res = ScreenResolution.getResolution(mContext);
	int windowWidth = res.first.intValue(), windowHeight = res.second.intValue();
	float windowRatio = windowWidth / (float) windowHeight;
	float videoRatio = aspectRatio <= 0.01f ? mVideoAspectRatio : aspectRatio;
	mSurfaceHeight = mVideoHeight;
	mSurfaceWidth = mVideoWidth;
	if (VIDEO_LAYOUT_ORIGIN == layout && mSurfaceWidth < windowWidth && mSurfaceHeight < windowHeight) {
		lp.width = (int) (mSurfaceHeight * videoRatio);
		lp.height = mSurfaceHeight;
	} else if (layout == VIDEO_LAYOUT_ZOOM) {
		lp.width = windowRatio > videoRatio ? windowWidth : (int) (videoRatio * windowHeight);
		lp.height = windowRatio < videoRatio ? windowHeight : (int) (windowWidth / videoRatio);
	} else if (layout == VIDEO_LAYOUT_FIT_PARENT) {
		ViewGroup parent = (ViewGroup) getParent();
		float parentRatio = ((float) parent.getWidth()) / ((float) parent.getHeight());
		lp.width = (parentRatio < videoRatio) ? parent.getWidth() : Math.round(((float) parent.getHeight()) * videoRatio);
		lp.height = (parentRatio > videoRatio) ? parent.getHeight() : Math.round(((float) parent.getWidth()) / videoRatio);
	} else {
		boolean full = layout == VIDEO_LAYOUT_STRETCH;
		lp.width = (full || windowRatio < videoRatio) ? windowWidth : (int) (videoRatio * windowHeight);
		lp.height = (full || windowRatio > videoRatio) ? windowHeight : (int) (windowWidth / videoRatio);
	}
	setLayoutParams(lp);
	getHolder().setFixedSize(mSurfaceWidth, mSurfaceHeight);
   Log.d("VIDEO: %dx%dx%f, Surface: %dx%d, LP: %dx%d, Window: %dx%dx%f", mVideoWidth, mVideoHeight, mVideoAspectRatio, mSurfaceWidth, mSurfaceHeight, lp.width, lp.height, windowWidth, windowHeight, windowRatio);
   mVideoLayout = layout;
   mAspectRatio = aspectRatio;
 }
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:43,代码来源:VideoView.java

示例3: init

import io.vov.vitamio.utils.ScreenResolution; //导入方法依赖的package包/类
private void init() {
    // 获取屏幕宽度
    Pair<Integer, Integer> screenPair = ScreenResolution.getResolution(this);
    mScreenWidth = screenPair.first;
    // 设置网络资源地址
    mVideoView.setVideoPath(mPlayUrl);
    // 设置缓冲大小为2M
    mVideoView.setBufferSize(1024 * 1024 * 2);

    initVolumeWithLight();
    addVideoViewListener();
    addSeekBarListener();
    addTouchListener();
}
 
开发者ID:WangZhiYao,项目名称:VideoDemo,代码行数:15,代码来源:VideoPlayActivity.java

示例4: setVideoLayout

import io.vov.vitamio.utils.ScreenResolution; //导入方法依赖的package包/类
/**
 * Set the display options
 *
 * @param layout      <ul>
 *                    <li>{@link #VIDEO_LAYOUT_ORIGIN}
 *                    <li>{@link #VIDEO_LAYOUT_SCALE}
 *                    <li>{@link #VIDEO_LAYOUT_STRETCH}
 *                    <li>{@link #VIDEO_LAYOUT_FIT_PARENT}
 *                    <li>{@link #VIDEO_LAYOUT_ZOOM}
 *                    </ul>
 * @param aspectRatio video aspect ratio, will audo detect if 0.
 */
public void setVideoLayout(int layout, float aspectRatio) {
    LayoutParams lp = getLayoutParams();
    Pair<Integer, Integer> res = ScreenResolution.getResolution(mContext);
    int windowWidth = res.first.intValue(), windowHeight = res.second.intValue();
    float windowRatio = windowWidth / (float) windowHeight;
    float videoRatio = aspectRatio <= 0.01f ? mVideoAspectRatio : aspectRatio;
    mSurfaceHeight = mVideoHeight;
    mSurfaceWidth = mVideoWidth;
    if (VIDEO_LAYOUT_ORIGIN == layout && mSurfaceWidth < windowWidth && mSurfaceHeight < windowHeight) {
        lp.width = (int) (mSurfaceHeight * videoRatio);
        lp.height = mSurfaceHeight;
    } else if (layout == VIDEO_LAYOUT_ZOOM) {
        lp.width = windowRatio > videoRatio ? windowWidth : (int) (videoRatio * windowHeight);
        lp.height = windowRatio < videoRatio ? windowHeight : (int) (windowWidth / videoRatio);
    } else if (layout == VIDEO_LAYOUT_FIT_PARENT) {
        ViewGroup parent = (ViewGroup) getParent();
        float parentRatio = ((float) parent.getWidth()) / ((float) parent.getHeight());
        lp.width = (parentRatio < videoRatio) ? parent.getWidth() : Math.round(((float) parent.getHeight()) * videoRatio);
        lp.height = (parentRatio > videoRatio) ? parent.getHeight() : Math.round(((float) parent.getWidth()) / videoRatio);
    } else {
        boolean full = layout == VIDEO_LAYOUT_STRETCH;
        lp.width = (full || windowRatio < videoRatio) ? windowWidth : (int) (videoRatio * windowHeight);
        lp.height = (full || windowRatio > videoRatio) ? windowHeight : (int) (windowWidth / videoRatio);
    }
    setLayoutParams(lp);
    getHolder().setFixedSize(mSurfaceWidth, mSurfaceHeight);
    Log.d("VIDEO: %dx%dx%f, Surface: %dx%d, LP: %dx%d, Window: %dx%dx%f", mVideoWidth, mVideoHeight, mVideoAspectRatio, mSurfaceWidth, mSurfaceHeight, lp.width, lp.height, windowWidth, windowHeight, windowRatio);
    mVideoLayout = layout;
    mAspectRatio = aspectRatio;
}
 
开发者ID:WangZhiYao,项目名称:VideoDemo,代码行数:43,代码来源:VideoView.java

示例5: setVideoLayout

import io.vov.vitamio.utils.ScreenResolution; //导入方法依赖的package包/类
/**
 * Set the display options
 *
 * @param layout      <ul>
 *                    <li>{@link #VIDEO_LAYOUT_ORIGIN}
 *                    <li>{@link #VIDEO_LAYOUT_SCALE}
 *                    <li>{@link #VIDEO_LAYOUT_STRETCH}
 *                    <li>{@link #VIDEO_LAYOUT_ZOOM}
 *                    <li>{@link #VIDEO_LAYOUT_FIT_PARENT}
 *                    </ul>
 * @param aspectRatio video aspect ratio, will audo detect if 0.
 */
public void setVideoLayout(int layout, float aspectRatio) {
  LayoutParams lp = getLayoutParams();
  Pair<Integer, Integer> res = ScreenResolution.getResolution(mContext);
  int windowWidth = res.first.intValue(), windowHeight = res.second.intValue();
  float windowRatio = windowWidth / (float) windowHeight;
  float videoRatio = aspectRatio <= 0.01f ? mVideoAspectRatio : aspectRatio;
  mSurfaceHeight = mVideoHeight;
  mSurfaceWidth = mVideoWidth;
  if (VIDEO_LAYOUT_ORIGIN == layout && mSurfaceWidth < windowWidth && mSurfaceHeight < windowHeight) {
    lp.width = (int) (mSurfaceHeight * videoRatio);
    lp.height = mSurfaceHeight;
  } else if (layout == VIDEO_LAYOUT_ZOOM) {
    lp.width = windowRatio > videoRatio ? windowWidth : (int) (videoRatio * windowHeight);
    lp.height = windowRatio < videoRatio ? windowHeight : (int) (windowWidth / videoRatio);
  } else if (layout == VIDEO_LAYOUT_FIT_PARENT) {
    ViewGroup parent = (ViewGroup) getParent();
    float parentRatio = ((float) parent.getWidth()) / ((float) parent.getHeight());
    lp.width = (parentRatio < videoRatio) ? parent.getWidth() : Math.round(((float) parent.getHeight()) * videoRatio);
    lp.height = (parentRatio > videoRatio) ? parent.getHeight() : Math.round(((float) parent.getWidth()) / videoRatio);
  } else {
    boolean full = layout == VIDEO_LAYOUT_STRETCH;
    lp.width = (full || windowRatio < videoRatio) ? windowWidth : (int) (videoRatio * windowHeight);
    lp.height = (full || windowRatio > videoRatio) ? windowHeight : (int) (windowWidth / videoRatio);
  }
  setLayoutParams(lp);
  getHolder().setFixedSize(mSurfaceWidth, mSurfaceHeight);
  Log.d("VIDEO: %dx%dx%f, Surface: %dx%d, LP: %dx%d, Window: %dx%dx%f", mVideoWidth, mVideoHeight, mVideoAspectRatio, mSurfaceWidth, mSurfaceHeight, lp.width, lp.height, windowWidth, windowHeight, windowRatio);
  mVideoLayout = layout;
  mAspectRatio = aspectRatio;
}
 
开发者ID:shegang,项目名称:meishiDemo,代码行数:43,代码来源:VideoView.java

示例6: resizeImageViewOnScreenSize

import io.vov.vitamio.utils.ScreenResolution; //导入方法依赖的package包/类
/**
 * 按 屏幕比例 缩放图片
 */
public static void resizeImageViewOnScreenSize(Context context, View view, int numColumns,
                                               int horizontalSpacing, int zoomX, int zoomY) {
    if (view == null) {
        return;
    }
    if (screenPair == null) {
        screenPair = ScreenResolution.getResolution(context);
    }
    android.view.ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
    layoutParams.width = screenPair.first / numColumns - horizontalSpacing * (numColumns - 1);
    layoutParams.height = layoutParams.width * zoomY / zoomX;
}
 
开发者ID:hezhubo,项目名称:HPlayer,代码行数:16,代码来源:Utility.java

示例7: setVideoLayout

import io.vov.vitamio.utils.ScreenResolution; //导入方法依赖的package包/类
/**
 * Set the display options
 *
 * @param layout      <ul>
 *                    <li>{@link #VIDEO_LAYOUT_ORIGIN}
 *                    <li>{@link #VIDEO_LAYOUT_SCALE}
 *                    <li>{@link #VIDEO_LAYOUT_STRETCH}
 *                    <li>{@link #VIDEO_LAYOUT_FIT_PARENT}
 *                    <li>{@link #VIDEO_LAYOUT_ZOOM}
 *                    </ul>
 * @param aspectRatio video aspect ratio, will audo detect if 0.
 */
public void setVideoLayout(int layout, float aspectRatio) {
	LayoutParams lp = getLayoutParams();
	Pair<Integer, Integer> res = ScreenResolution.getResolution(mContext);
	int windowWidth = res.first.intValue(), windowHeight = res.second.intValue();
	float windowRatio = windowWidth / (float) windowHeight;
	float videoRatio = aspectRatio <= 0.01f ? mVideoAspectRatio : aspectRatio;
	mSurfaceHeight = mVideoHeight;
	mSurfaceWidth = mVideoWidth;
	if (VIDEO_LAYOUT_ORIGIN == layout && mSurfaceWidth < windowWidth && mSurfaceHeight < windowHeight) {
		lp.width = (int) (mSurfaceHeight * videoRatio);
		lp.height = mSurfaceHeight;
	} else if (layout == VIDEO_LAYOUT_ZOOM) {
		lp.width = windowRatio > videoRatio ? windowWidth : (int) (videoRatio * windowHeight);
		lp.height = windowRatio < videoRatio ? windowHeight : (int) (windowWidth / videoRatio);
	} else if (layout == VIDEO_LAYOUT_FIT_PARENT) {
		ViewGroup parent = (ViewGroup) getParent();
		float parentRatio = ((float) parent.getWidth()) / ((float) parent.getHeight());
		lp.width = (parentRatio < videoRatio) ? parent.getWidth() : Math.round(((float) parent.getHeight()) * videoRatio);
		lp.height = (parentRatio > videoRatio) ? parent.getHeight() : Math.round(((float) parent.getWidth()) / videoRatio);
	} else {
		boolean full = layout == VIDEO_LAYOUT_STRETCH;
		lp.width = (full || windowRatio < videoRatio) ? windowWidth : (int) (videoRatio * windowHeight);
		lp.height = (full || windowRatio > videoRatio) ? windowHeight : (int) (windowWidth / videoRatio);
	}
	setLayoutParams(lp);
	getHolder().setFixedSize(mSurfaceWidth, mSurfaceHeight);
   Log.d("VIDEO: %dx%dx%f, Surface: %dx%d, LP: %dx%d, Window: %dx%dx%f", mVideoWidth, mVideoHeight, mVideoAspectRatio, mSurfaceWidth, mSurfaceHeight, lp.width, lp.height, windowWidth, windowHeight, windowRatio);
   mVideoLayout = layout;
   mAspectRatio = aspectRatio;
       // 初始化
       videoWidth = lp.width;
       videoHeight = lp.height;
       currentScale = 1f;
 }
 
开发者ID:hezhubo,项目名称:HPlayer,代码行数:47,代码来源:VideoView.java

示例8: setScreenWidth

import io.vov.vitamio.utils.ScreenResolution; //导入方法依赖的package包/类
/**
 * 设置当前屏幕的宽(与方向有关)
 */
public void setScreenWidth(Context context) {
    Pair<Integer, Integer> screenPair = ScreenResolution.getResolution(context);
    width = screenPair.first;
}
 
开发者ID:hezhubo,项目名称:HPlayer,代码行数:8,代码来源:PlayerGesture.java


注:本文中的io.vov.vitamio.utils.ScreenResolution.getResolution方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。