本文整理匯總了Java中android.view.Surface.isValid方法的典型用法代碼示例。如果您正苦於以下問題:Java Surface.isValid方法的具體用法?Java Surface.isValid怎麽用?Java Surface.isValid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.view.Surface
的用法示例。
在下文中一共展示了Surface.isValid方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setVideoResourceId
import android.view.Surface; //導入方法依賴的package包/類
/**
* Sets the raw resource ID of video to play.
*
* @param id The raw resource ID.
*/
public void setVideoResourceId(@RawRes int id) {
if (id == mVideoResourceId) {
return;
}
mVideoResourceId = id;
Surface surface = mSurfaceView.getHolder().getSurface();
if (surface != null && surface.isValid()) {
closeVideo();
openVideo(surface);
}
}
示例2: maybeStartHostedTest
import android.view.Surface; //導入方法依賴的package包/類
private void maybeStartHostedTest() {
if (hostedTest == null || hostedTestStarted) {
return;
}
Surface surface = surfaceView.getHolder().getSurface();
if (surface != null && surface.isValid()) {
hostedTestStarted = true;
Log.d(TAG, "Starting test.");
hostedTest.onStart(this, surface);
checkCanStopRunnable.startChecking();
}
}
示例3: setOutputSurface
import android.view.Surface; //導入方法依賴的package包/類
/**
* Set the output surface to consume the stream of edited camera frames. This is probably
* from a SurfaceView or TextureView. Please make sure it's valid.
*
* @param outputSurface a valid surface to consume a stream of edited frames from the camera
*/
@AnyThread
@Override
public synchronized void setOutputSurface(Surface outputSurface) {
if (isRunning()) {
if (!outputSurface.isValid()) {
throw new IllegalArgumentException("output was invalid");
}
rgbOutAlloc.setSurface(outputSurface);
outputSurfaceIsSet = true;
Log.d(TAG, "output surface was set");
}
}
示例4: startBouncing
import android.view.Surface; //導入方法依賴的package包/類
private void startBouncing() {
final Surface surface = mSurfaceView2.getHolder().getSurface();
if (surface == null || !surface.isValid()) {
Log.w(TAG, "mSurfaceView2 is not ready");
return;
}
mBounceThread = new Thread() {
@Override
public void run() {
while (true) {
long startWhen = System.nanoTime();
for (int i = 0; i < BOUNCE_STEPS; i++) {
if (!mBouncing) return;
drawBouncingCircle(surface, i);
}
for (int i = BOUNCE_STEPS; i > 0; i--) {
if (!mBouncing) return;
drawBouncingCircle(surface, i);
}
long duration = System.nanoTime() - startWhen;
double framesPerSec = 1000000000.0 / (duration / (BOUNCE_STEPS * 2.0));
Log.d(TAG, "Bouncing at " + framesPerSec + " fps");
}
}
};
mBouncing = true;
mBounceThread.setName("Bouncer");
mBounceThread.start();
}
示例5: startCamera
import android.view.Surface; //導入方法依賴的package包/類
@Override
public void startCamera() {
try {
CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(cameraID);
StreamConfigurationMap configMap = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
int width = textureView.getWidth();
int height = textureView.getHeight();
//設置一個合適的預覽尺寸,防止圖像拉伸
// previewSize = getPreferredPreviewSize(configMap.getOutputSizes(SurfaceTexture.class), width, height);
previewSize = Util.getPreferredPreviewSize(configMap.getOutputSizes(ImageFormat.JPEG), width, height);
surfaceTexture.setDefaultBufferSize(previewSize.getWidth(),previewSize.getHeight());
Log.i(TAG, "previewSize info:" + previewSize.getWidth() + "x" + previewSize.getHeight());
surface = new Surface(surfaceTexture);
builder =cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
if (surface.isValid()) {
builder.addTarget(surface);
}
Log.i(TAG, "mTextureView info:" + textureView.getWidth() + "x" + textureView.getHeight());
cameraDevice.createCaptureSession(Arrays.asList(surface),sessionStateCallback,null);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
示例6: setSurface
import android.view.Surface; //導入方法依賴的package包/類
private void setSurface(Surface surface) {
if (surface.isValid() && getNativeSurface(mId) == null) {
mSurface = surface;
setNativeSurface(mId, mSurface);
onSurfaceCreated();
}
}