本文整理汇总了Java中android.view.SurfaceHolder类的典型用法代码示例。如果您正苦于以下问题:Java SurfaceHolder类的具体用法?Java SurfaceHolder怎么用?Java SurfaceHolder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SurfaceHolder类属于android.view包,在下文中一共展示了SurfaceHolder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import android.view.SurfaceHolder; //导入依赖的package包/类
private void init() {
// init surfaceholder
SurfaceHolder holder = getHolder();
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
holder.addCallback(this);
WindowManager manager = (WindowManager) getContext().getSystemService(
Context.WINDOW_SERVICE);
Display display = manager.getDefaultDisplay();
screenWidth = display.getWidth();
screenHeight = display.getHeight();
int width = screenWidth >= screenHeight ? screenWidth : screenHeight;
int height = screenWidth + screenHeight - width;
int rotation = display.getRotation();
mScanner = CameraScanner.getInstance();
mScanner.setRotation(0); //此处直接设为0,配合竖屏展示
mScanner.setReqSize(width, height);
}
示例2: surfaceChanged
import android.view.SurfaceHolder; //导入依赖的package包/类
public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
Log.d(TAG, "call surfaceChanged event");
synchronized(mSyncObject) {
if (!mSurfaceExist) {
mSurfaceExist = true;
checkCurrentState();
} else {
/** Surface changed. We need to stop camera and restart with new parameters */
/* Pretend that old surface has been destroyed */
mSurfaceExist = false;
checkCurrentState();
/* Now use new surface. Say we have it now */
mSurfaceExist = true;
checkCurrentState();
}
}
}
示例3: initVideoView
import android.view.SurfaceHolder; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private void initVideoView(Context ctx) {
mContext = ctx;
mVideoWidth = 0;
mVideoHeight = 0;
getHolder().setFormat(PixelFormat.RGBA_8888); // PixelFormat.RGB_565
getHolder().addCallback(mSHCallback);
// this value only use Hardware decoder before Android 2.3
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB && mHardwareDecoder) {
getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
setFocusable(true);
setFocusableInTouchMode(true);
requestFocus();
mCurrentState = STATE_IDLE;
mTargetState = STATE_IDLE;
if (ctx instanceof Activity) {
((Activity) ctx).setVolumeControlStream(AudioManager.STREAM_MUSIC);
}
}
示例4: surfaceChanged
import android.view.SurfaceHolder; //导入依赖的package包/类
public void surfaceChanged(SurfaceHolder holder, int format, int w,
int h) {
mSurfaceHolder = holder;
if (mMediaPlayer != null) {
mMediaPlayer.setDisplay(mSurfaceHolder);
}
mSurfaceWidth = w;
mSurfaceHeight = h;
boolean isValidState = (mTargetState == STATE_PLAYING);
boolean hasValidSize = (mVideoWidth == w && mVideoHeight == h);
if (mMediaPlayer != null && isValidState && hasValidSize) {
if (mSeekWhenPrepared != 0) {
seekTo(mSeekWhenPrepared);
}
start();
if (mMediaController != null) {
if (mMediaController.isShowing()) {
mMediaController.hide();
}
mMediaController.show();
}
}
}
示例5: openDriver
import android.view.SurfaceHolder; //导入依赖的package包/类
/**
* Opens the camera driver and initializes the hardware parameters.
*
* @param holder The surface object which the camera will draw preview frames into.
* @throws IOException Indicates the camera driver failed to open.
*/
public void openDriver(SurfaceHolder holder) throws IOException {
if (camera == null) {
camera = Camera.open();
if (camera == null) {
throw new IOException();
}
camera.setPreviewDisplay(holder);
if (!initialized) {
initialized = true;
configManager.initFromCameraParameters(camera);
}
configManager.setDesiredCameraParameters(camera);
//FIXME
// SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
//�Ƿ�ʹ��ǰ��
// if (prefs.getBoolean(PreferencesActivity.KEY_FRONT_LIGHT, false)) {
// FlashlightManager.enableFlashlight();
// }
FlashlightManager.enableFlashlight();
}
}
示例6: surfaceChanged
import android.view.SurfaceHolder; //导入依赖的package包/类
public void surfaceChanged(SurfaceHolder holder, int format,
int in_width, int in_height) {
Log.d(TAG, "ViESurfaceRender::surfaceChanged");
changeDestRect(in_width, in_height);
Log.d(TAG, "ViESurfaceRender::surfaceChanged" +
" in_width:" + in_width + " in_height:" + in_height +
" srcRect.left:" + srcRect.left +
" srcRect.top:" + srcRect.top +
" srcRect.right:" + srcRect.right +
" srcRect.bottom:" + srcRect.bottom +
" dstRect.left:" + dstRect.left +
" dstRect.top:" + dstRect.top +
" dstRect.right:" + dstRect.right +
" dstRect.bottom:" + dstRect.bottom);
}
示例7: surfaceChanged
import android.view.SurfaceHolder; //导入依赖的package包/类
@Override
public void surfaceChanged(SurfaceHolder holder, int format,
int width, int height) {
mSurfaceHolder = holder;
mIsFormatChanged = true;
mFormat = format;
mWidth = width;
mHeight = height;
// mMeasureHelper.setVideoSize(width, height);
ISurfaceHolder surfaceHolder = new InternalSurfaceHolder(mWeakSurfaceView.get(), mSurfaceHolder);
for (IRenderCallback renderCallback : mRenderCallbackMap.keySet()) {
renderCallback.onSurfaceChanged(surfaceHolder, format, width, height);
}
}
示例8: openDriver
import android.view.SurfaceHolder; //导入依赖的package包/类
/**
* Opens the camera driver and initializes the hardware parameters.
*
* @param holder The surface object which the camera will draw preview frames into.
* @throws IOException Indicates the camera driver failed to open.
*/
public void openDriver(SurfaceHolder holder) throws IOException {
if (camera == null) {
camera = Camera.open();
if (camera == null) {
throw new IOException();
}
camera.setPreviewDisplay(holder);
if (!initialized) {
initialized = true;
configManager.initFromCameraParameters(camera);
}
configManager.setDesiredCameraParameters(camera);
//FIXME
// SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
//�Ƿ�ʹ��ǰ��
// if (prefs.getBoolean(PreferencesActivity.KEY_FRONT_LIGHT, false)) {
// FlashlightManager.enableFlashlight();
// }
FlashlightManager.enableFlashlight();
}
}
示例9: initView
import android.view.SurfaceHolder; //导入依赖的package包/类
@Override
protected void initView() {
mSurfaceview = (SurfaceView) findViewById(R.id.surfaceview);
mRlTakeVedio = (RelativeLayout) findViewById(R.id.rl_take_vedio);
mIvCancel = (ImageView) findViewById(R.id.iv_cancel);
mTrpbController = (TimeRoundProgressBar) findViewById(R.id.trpb_controller);
mRlConfrmVedio = (RelativeLayout) findViewById(R.id.rl_confrm_vedio);
mIvDelete = (ImageView) findViewById(R.id.iv_delete);
mIvConfirm = (ImageView) findViewById(R.id.iv_confirm);
mDialog = ERecorderActivityImpl.getCreateVedioDialog(getActivity());
mTrpbController.setMax(mRecordTime);
SurfaceHolder holder = mSurfaceview.getHolder();// 取得holder
holder.setFormat(PixelFormat.TRANSPARENT);
holder.setKeepScreenOn(true);
holder.addCallback(this); // holder加入回调接口
}
示例10: surfaceCreated
import android.view.SurfaceHolder; //导入依赖的package包/类
public void surfaceCreated(SurfaceHolder holder) {
Canvas canvas = surfaceHolder.lockCanvas();
if(canvas != null) {
Rect dst = surfaceHolder.getSurfaceFrame();
if(dst != null) {
changeDestRect(dst.right - dst.left, dst.bottom - dst.top);
Log.d(TAG, "ViESurfaceRender::surfaceCreated" +
" dst.left:" + dst.left +
" dst.top:" + dst.top +
" dst.right:" + dst.right +
" dst.bottom:" + dst.bottom +
" srcRect.left:" + srcRect.left +
" srcRect.top:" + srcRect.top +
" srcRect.right:" + srcRect.right +
" srcRect.bottom:" + srcRect.bottom +
" dstRect.left:" + dstRect.left +
" dstRect.top:" + dstRect.top +
" dstRect.right:" + dstRect.right +
" dstRect.bottom:" + dstRect.bottom);
}
surfaceHolder.unlockCanvasAndPost(canvas);
}
}
示例11: onResume
import android.view.SurfaceHolder; //导入依赖的package包/类
@Override
protected void onResume() {
super.onResume();
SurfaceHolder surfaceHolder = surfaceView.getHolder();
if (hasSurface) {
initCamera(surfaceHolder);
} else {
surfaceHolder.addCallback(this);
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
decodeFormats = null;
characterSet = null;
playBeep = true;
AudioManager audioService = (AudioManager) getSystemService(AUDIO_SERVICE);
if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
playBeep = false;
}
initBeepSound();
vibrate = true;
}
示例12: initCamera
import android.view.SurfaceHolder; //导入依赖的package包/类
private void initCamera(SurfaceHolder surfaceHolder) {
if (surfaceHolder == null) {
return;
}
if (cameraManager.isOpen()) {
return;
}
try {
cameraManager.openDriver(surfaceHolder);
if (handler == null) {
handler = new CaptureActivityHandler(this, decodeFormats,
decodeHints, characterSet, cameraManager);
}
decodeOrStoreSavedBitmap(null, null);
} catch (IOException ioe) {
displayFrameworkBugMessageAndExit();
} catch (RuntimeException e) {
displayFrameworkBugMessageAndExit();
}
}
示例13: openDriver
import android.view.SurfaceHolder; //导入依赖的package包/类
/**
* Opens the camera driver and initializes the hardware parameters.
*
* @param holder The surface object which the camera will draw preview frames into.
* @throws IOException Indicates the camera driver failed to open.
*/
public void openDriver(SurfaceHolder holder) throws IOException {
if (camera == null) {
camera = Camera.open();
if (camera == null) {
throw new IOException();
}
camera.setPreviewDisplay(holder);
if (!initialized) {
initialized = true;
configManager.initFromCameraParameters(camera);
}
configManager.setDesiredCameraParameters(camera);
//FIXME
// SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
//是否使用前灯
// if (prefs.getBoolean(PreferencesActivity.KEY_FRONT_LIGHT, false)) {
// FlashlightManager.enableFlashlight();
// }
FlashlightManager.enableFlashlight();
}
}
示例14: onCreate
import android.view.SurfaceHolder; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public void onCreate(Bundle icicle){
super.onCreate(icicle);
Log.e(TAG, "onCreate");
setContentView(R.layout.cameraview);
mSurfaceView = (SurfaceView) findViewById(R.id.surface_camera);
mSurfaceHolder = mSurfaceView.getHolder();
mSurfaceHolder.addCallback(this);
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
示例15: setDisplay
import android.view.SurfaceHolder; //导入依赖的package包/类
/**
* Sets the SurfaceHolder to use for displaying the video portion of the
* media. This call is optional. Not calling it when playing back a video will
* result in only the audio track being played.
*
* @param sh the SurfaceHolder to use for video display
*/
public void setDisplay(SurfaceHolder sh) {
if (sh == null) {
releaseDisplay();
} else {
mSurfaceHolder = sh;
mSurface = sh.getSurface();
_setVideoSurface(mSurface);
updateSurfaceScreenOn();
}
}