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); }
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(); } } }
@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); } }
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(); } } }
/** * 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(); } }
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); }
@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); } }
@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加入回调接口 }
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); } }
@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; }
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(); } }
/** * 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(); } }
@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); }
/** * 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(); } }
@Override public void surfaceCreated(final SurfaceHolder holder) { ThreadUtils.checkIsOnMainThread(); eglRenderer.createEglSurface(holder.getSurface()); surfaceWidth = surfaceHeight = 0; updateSurfaceSize(); }
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height ) { Camera.Parameters parameters = camera.getParameters(); List<Camera.Size> previewSizes = parameters.getSupportedPreviewSizes(); Camera.Size previewSize = previewSizes.get(previewSizes.size()-1); Camera.Parameters p = camera.getParameters(); p.setPreviewSize( previewSize.width, previewSize.height ); camera.setParameters( p ); try{camera.setPreviewDisplay( holder );} catch(IOException e){e.printStackTrace();} camera.startPreview(); }
@Override public CameraActions startPreview(SurfaceHolder holder) throws IOException { if (holder == null) { throw new NullPointerException("You cannot start preview without a preview surface"); } camera.setPreviewDisplay(holder); camera.startPreview(); return new DefaultCameraActions(this); }
private void initCamera(SurfaceHolder surfaceHolder) { try { CameraManager.get().openDriver(surfaceHolder); } catch (IOException ioe) { return; } catch (RuntimeException e) { return; } if (handler == null) { handler = new CaptureActivityHandler(this, decodeFormats, characterSet); } }
public void surfaceDestroyed(SurfaceHolder holder) { this.mSurfaceHolder = null; this.mIsFormatChanged = false; this.mFormat = 0; this.mWidth = 0; this.mHeight = 0; ISurfaceHolder surfaceHolder = new InternalSurfaceHolder((SurfaceRenderView) this .mWeakSurfaceView.get(), this.mSurfaceHolder); for (IRenderCallback renderCallback : this.mRenderCallbackMap.keySet()) { renderCallback.onSurfaceDestroyed(surfaceHolder); } }
private void initView(Context context) { mMeasureHelper = new MeasureHelper(this); mSurfaceCallback = new SurfaceCallback(this); getHolder().addCallback(mSurfaceCallback); //noinspection deprecation getHolder().setType(SurfaceHolder.SURFACE_TYPE_NORMAL); }
public CameraSurface( Context context ) { super( context ); // We're implementing the Callback interface and want to get notified // about certain surface events. getHolder().addCallback( this ); // We're changing the surface to a PUSH surface, meaning we're receiving // all buffer data from another component - the camera, in this case. getHolder().setType( SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS ); }
public void surfaceCreated(SurfaceHolder holder) { LogTag.i("mSHCallback:surfaceCreated()"); if (VideoViewH264m3u8_4D.this.mSurfaceHolder == null) { VideoViewH264m3u8_4D.this.mSurfaceHolder = holder; VideoViewH264m3u8_4D.this.openVideo(); } }
@Override public void setDisplay(SurfaceHolder sh) { if (sh == null) { setSurface(null); } else { setSurface(sh.getSurface()); } }
@Override public void surfaceCreated(SurfaceHolder holder) { fireHeight = getHeight() * 3 / 4; halfWidth = getWidth() / 2; fireWidth = halfWidth / 4; distance = fireWidth / 8; running = true; new RefreshThread().start(); }
@Override public void surfaceCreated(SurfaceHolder holder) { if (holder == null) { Log.e(TAG, "*** WARNING *** surfaceCreated() gave us a null surface!"); } if (!hasSurface) { hasSurface = true; initCamera(holder); } }
private void createSurfaceInternal(Object nativeWindow) { if (!(nativeWindow instanceof SurfaceHolder) && !(nativeWindow instanceof SurfaceTexture)) { throw new IllegalStateException("Input must be either a SurfaceHolder or SurfaceTexture"); } checkIsNotReleased(); if (eglSurface != EGL10.EGL_NO_SURFACE) { throw new RuntimeException("Already has an EGLSurface"); } int[] surfaceAttribs = {EGL10.EGL_NONE}; eglSurface = egl.eglCreateWindowSurface(eglDisplay, eglConfig, nativeWindow, surfaceAttribs); if (eglSurface == EGL10.EGL_NO_SURFACE) { throw new RuntimeException( "Failed to create window surface: 0x" + Integer.toHexString(egl.eglGetError())); } }
@Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { synchronized (ImageSurfaceView.class) { mRectDes.set(0, 0, width, height); mSurfaceHeight = height; mSurfaceWidth = width; init(default_scale); if (mBitmap != null) { showBitmap(); } } }
public void surfaceDestroyed(SurfaceHolder holder) { // after we return from this we can't use the surface any more mSurfaceHolder = null; mSurfaceWidth = 0; mSurfaceHeight = 0; stopPlayback(); }
private void initCamera(SurfaceHolder surfaceHolder) { try { CameraManager.get().openDriver(surfaceHolder); } catch (IOException ioe) { return; } catch (RuntimeException e) { return; } if (handler == null) { handler = new CaptureActivityHandler(this, decodeFormats, characterSet, viewfinderView, this); } }
@Override public void surfaceDestroyed(SurfaceHolder holder) { if (autoFocusManager != null) { autoFocusManager.stop(); autoFocusManager = null; } }
@Override public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) { super.onSurfaceChanged(holder, format, width, height); draw(); }
@Override public void surfaceCreated(SurfaceHolder holder) { openCamera(); }
@Override public void setDisplay(SurfaceHolder surfaceHolder) { if(isLegalState()){ mDecoder.setDisplay(surfaceHolder); } }
@Override public void onCreate(SurfaceHolder holder) { super.onCreate(holder); setWatchFaceStyle(new WatchFaceStyle.Builder(MyWatchFace.this) .setCardPeekMode(WatchFaceStyle.PEEK_MODE_VARIABLE) .setBackgroundVisibility(WatchFaceStyle.BACKGROUND_VISIBILITY_INTERRUPTIVE) .setShowSystemUiTime(false) .setAcceptsTapEvents(true) .build()); Resources resources = MyWatchFace.this.getResources(); mYOffset = resources.getDimension(R.dimen.digital_y_offset); mY1Offset = resources.getDimension(R.dimen.digital_y1_offset); mLowTextSize = resources.getDimension(R.dimen.low_temp_text_size); mHighTextSize = resources.getDimension(R.dimen.high_temp_text_size); dp_10 = resources.getDimension(R.dimen.dp_10); dp_5 = resources.getDimension(R.dimen.dp_5); mBackgroundPaint = new Paint(); mBackgroundPaint.setColor(resources.getColor(R.color.colorPrimary)); mTextPaint = new Paint(); mTextPaint = createTextPaint(resources.getColor(R.color.digital_text)); dateTextPaint = new Paint(); dateTextPaint = createTextPaint(resources.getColor(R.color.light_white)); lineTextPaint = new Paint(); lineTextPaint = createTextPaint(resources.getColor(R.color.light_white)); mLowTempPaint = new Paint(); mLowTempPaint = createTextPaint(resources.getColor(R.color.light_white)); mHighTempPaint = new Paint(); mHighTempPaint = createTextPaint(resources.getColor(R.color.white)); mCalendar = Calendar.getInstance(); mWearClient = new GoogleApiClient.Builder(MyWatchFace.this) .addApi(Wearable.API) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .build(); }
public void surfaceCreated(SurfaceHolder holder) { /* Do nothing. Wait until surfaceChanged delivered */ }