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


Java Display.getRefreshRate方法代码示例

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


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

示例1: getDisplayRefreshNsec

import android.view.Display; //导入方法依赖的package包/类
/**
 * Obtains the approximate refresh time, in nanoseconds, of the default display associated
 * with the activity.
 * <p>
 * The actual refresh rate can vary slightly (e.g. 58-62fps on a 60fps device).
 */
public static long getDisplayRefreshNsec(Activity activity) {
    Display display = ((WindowManager)
            activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    double displayFps = display.getRefreshRate();
    long refreshNs = Math.round(1000000000L / displayFps);
    Log.d(TAG, "refresh rate is " + displayFps + " fps --> " + refreshNs + " ns");
    return refreshNs;
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:15,代码来源:MiscUtils.java

示例2: run

import android.view.Display; //导入方法依赖的package包/类
public void run() {
    if (mCurrentState == STATE_PREPARED) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            if (mWaitForNewRate) {
                View v = mWindow.getDecorView();
                Display d = v.getDisplay();
                float currentRefreshRate = d.getRefreshRate();
                if (Math.abs(mRefreshRate - currentRefreshRate) > .1) {
                    if (DBG) Log.d(TAG, "current refresh rate is " + currentRefreshRate + " trying to switch to " + mRefreshRate);
                    mHandler.postDelayed(mRefreshRateCheckerAsync, 200);
                    return;
                }
                if (DBG) Log.d(TAG, "refresh rate before video start is " + currentRefreshRate);
            }
        }

        mCurrentState = STATE_REFRESH_PREPARED;

        if (mVideoWidth != 0 && mVideoHeight != 0) {
            mSurfaceController.setVideoSize(mVideoWidth, mVideoHeight, mVideoAspect);
            if (mEffectRenderer != null)
                mEffectRenderer.setVideoSize(mVideoWidth, mVideoHeight, mVideoAspect);
            mHandler.removeCallbacks(mPreparedAsync);
            mHandler.post(mPreparedAsync);

        } else {
            // We don't know the video size yet, but should start anyway.
            // The video size might be reported to us later, or not at all.
            // Wait 1 second, and play a video with no surface (sound only).
            mHandler.postDelayed(mPreparedAsync, 1000);
        }
    }
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:34,代码来源:Player.java


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