當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。