本文整理汇总了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();
}
}