本文整理汇总了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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例8: setScreenWidth
import io.vov.vitamio.utils.ScreenResolution; //导入方法依赖的package包/类
/**
* 设置当前屏幕的宽(与方向有关)
*/
public void setScreenWidth(Context context) {
Pair<Integer, Integer> screenPair = ScreenResolution.getResolution(context);
width = screenPair.first;
}