android.view.SurfaceView Java Examples
The following examples show how to use
android.view.SurfaceView.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RecordFBOActivity.java From pause-resume-video-recording with Apache License 2.0 | 6 votes |
@Override public void surfaceCreated(SurfaceHolder holder) { Log.d(TAG, "surfaceCreated holder=" + holder); File outputFile = new File(getFilesDir(), "fbo-gl-recording.mp4"); SurfaceView sv = (SurfaceView) findViewById(R.id.fboActivity_surfaceView); mRenderThread = new RenderThread(sv.getHolder(), new ActivityHandler(this), outputFile, MiscUtils.getDisplayRefreshNsec(this)); mRenderThread.setName("RecordFBO GL render"); mRenderThread.start(); mRenderThread.waitUntilReady(); mRenderThread.setRecordMethod(mSelectedRecordMethod); RenderHandler rh = mRenderThread.getHandler(); if (rh != null) { rh.sendSurfaceCreated(); } // start the draw events Choreographer.getInstance().postFrameCallback(this); }
Example #2
Source File: PlayMovieSurfaceActivity.java From grafika with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(getContentViewId()); mSurfaceView = (SurfaceView) findViewById(R.id.playMovie_surface); mSurfaceView.getHolder().addCallback(this); // Populate file-selection spinner. Spinner spinner = (Spinner) findViewById(R.id.playMovieFile_spinner); // Need to create one of these fancy ArrayAdapter thingies, and specify the generic layout // for the widget itself. mMovieFiles = MiscUtils.getFiles(getFilesDir(), "*.mp4"); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mMovieFiles); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner. spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(this); updateControls(); }
Example #3
Source File: CaptureActivity.java From QrScan with Apache License 2.0 | 6 votes |
/** * 初始化照相机和surfaceView,使zxing不断尝试从摄像头获取照片并解码 * 本方法在Activity的onResume中,以及在扫描功能被关闭后需要再次开启时调用 */ private void initZXingCamera() { SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view); 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; } vibrate = true; }
Example #4
Source File: MainActivity.java From open-quartz with Apache License 2.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.surface_view); /** View for OpenCV **/ mOpenCvCameraView = (OGView) findViewById(R.id.tutorial3_activity_java_surface_view); mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE); mOpenCvCameraView.setCvCameraViewListener(this); /** Gesture for Glass **/ mGestureDetector = new GestureDetector(this, this); }
Example #5
Source File: MultiVideoCallActivity.java From sealtalk-android with MIT License | 6 votes |
void addRemoteVideo(View singleRemoteView, SurfaceView video, String userId) { if (singleRemoteView == null) return; FrameLayout remoteVideoView = (FrameLayout) singleRemoteView.findViewById(R.id.viewlet_remote_video_user); remoteVideoView.removeAllViews(); if (video.getParent() != null) { ((ViewGroup) video.getParent()).removeView(video); } remoteVideoView.addView(video, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); // TextView remoteNameTextView = new TextView(this); // TextView tv = (TextView) singleRemoteView.findViewById(R.id.user_name); // ViewGroup.LayoutParams params = tv.getLayoutParams(); // remoteNameTextView.setLayoutParams(params); // remoteNameTextView.setTextAppearance(this, R.style.rc_voip_text_style_style); // UserInfo userInfo = RongContext.getInstance().getUserInfoFromCache(userId); // if (userInfo != null) { // remoteNameTextView.setText(userInfo.getName()); // } else { // remoteNameTextView.setText(userId); // } // remoteVideoView.addView(remoteNameTextView); remoteVideoView.setVisibility(View.VISIBLE); remoteVideoView.setTag(userId); }
Example #6
Source File: LiveStuffH4.java From goprohero with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set up a full-screen black window. requestWindowFeature(Window.FEATURE_NO_TITLE); Window window = getWindow(); window.setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); window.setBackgroundDrawableResource(android.R.color.black); setContentView(R.layout.activity_live_stuff); // Configure the view that renders live video. SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surfaceView); _surfaceHolder = surfaceView.getHolder(); _surfaceHolder.addCallback(this); _surfaceHolder.setFixedSize(320, 240); }
Example #7
Source File: MainActivity.java From opencv-android-sample with MIT License | 6 votes |
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { Log.i(TAG, "called onCreate"); super.onCreate(savedInstanceState); // Load ndk built module, as specified // in moduleName in build.gradle System.loadLibrary("native"); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_main); mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.camera_view); mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE); mOpenCvCameraView.setCvCameraViewListener(this); }
Example #8
Source File: DecoderActivity.java From android-quick-response-code with Apache License 2.0 | 6 votes |
@Override protected void onPause() { super.onPause(); Log.v(TAG, "onPause()"); if (handler != null) { handler.quitSynchronously(); handler = null; } cameraManager.closeDriver(); if (!hasSurface) { SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view); SurfaceHolder surfaceHolder = surfaceView.getHolder(); surfaceHolder.removeCallback(this); } }
Example #9
Source File: CarlifeActivity.java From apollo-DuerOS with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); EncryptSetupManager.getInstance(); LogUtil.d(TAG, "onCreate"); mTimeCarlifeStart = SystemClock.elapsedRealtime(); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_main); mRootView = (ViewGroup) findViewById(R.id.main_root_view); PreferenceUtil.getInstance().init(this); mCarLifeFragmentManager = new CarLifeFragmentManager(this); // initialize basefragment, must be called before using it's subclass BaseFragment.initBeforeAll(this); mCarLifeFragmentManager.showFragment(LaunchFragment.getInstance()); mSurfaceView = (SurfaceView) findViewById(R.id.main_video_surface_view); mSurfaceView.getHolder().addCallback(this); mMainActivityHandler = new MsgMainActivityHandler(); mLocationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); MsgHandlerCenter.registerMessageHandler(mMainActivityHandler); ErrorCodeReport.getInterface().init(this); mMainActivityHandler.sendEmptyMessageDelayed(CommonParams.MSG_CONNECT_INIT, 500); ControlTestWindow.getInstance().init(this, mRootView); SettingAboutWindow.getInstance().init(this, mRootView); initLaunchMode(getIntent()); mTimeCarlifeInit = SystemClock.elapsedRealtime(); LogUtil.d(TAG, "-QA_Test- OnCreate_InitTime = " + (mTimeCarlifeInit - mTimeCarlifeStart)); DebugLogUtil.getInstance().init(this); }
Example #10
Source File: EGLBase.java From Fatigue-Detection with MIT License | 5 votes |
EglSurface(final EGLBase egl, final Object surface) { if (DEBUG) Log.v(TAG, "EglSurface:"); if (!(surface instanceof SurfaceView) && !(surface instanceof Surface) && !(surface instanceof SurfaceHolder) && !(surface instanceof SurfaceTexture)) throw new IllegalArgumentException("unsupported surface"); mEgl = egl; mEglSurface = mEgl.createWindowSurface(surface); mWidth = mEgl.querySurface(mEglSurface, EGL14.EGL_WIDTH); mHeight = mEgl.querySurface(mEglSurface, EGL14.EGL_HEIGHT); if (DEBUG) Log.v(TAG, String.format("EglSurface:size(%d,%d)", mWidth, mHeight)); }
Example #11
Source File: MainActivity.java From pasm-yolov3-Android with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_main); validateCameraPermission(); classifier = initClassifier(); imageSaver = new ImageSaver(); imageSaver.createFolderIfNotExist(); mOpenCvCameraView= findViewById(R.id.cameraView1); mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE); mOpenCvCameraView.setCvCameraViewListener(this); }
Example #12
Source File: Tutorial1Activity.java From OpenCV-AndroidSamples with MIT License | 5 votes |
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { Log.i(TAG, "called onCreate"); super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_tutorial1); mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.tutorial1_activity_java_surface_view); mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE); mOpenCvCameraView.setCvCameraViewListener(this); }
Example #13
Source File: ScreenCaptureFragment.java From media-samples with Apache License 2.0 | 5 votes |
@Override public void onViewCreated(View view, Bundle savedInstanceState) { mSurfaceView = (SurfaceView) view.findViewById(R.id.surface); mSurface = mSurfaceView.getHolder().getSurface(); mButtonToggle = (Button) view.findViewById(R.id.toggle); mButtonToggle.setOnClickListener(this); }
Example #14
Source File: MapActivity.java From ETSMobile-Android2 with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_map); surfaceView = (SurfaceView) findViewById(R.id.activity_map_surfaceView); resetBtn = (ImageButton) findViewById(R.id.activity_map_reset); zoomBtn = (ImageButton) findViewById(R.id.activity_map_zoom); }
Example #15
Source File: CameraSourcePreview.java From Bluefruit_LE_Connect_Android_V2 with MIT License | 5 votes |
public CameraSourcePreview(Context context, AttributeSet attrs) { super(context, attrs); mContext = context; mStartRequested = false; mSurfaceAvailable = false; mSurfaceView = new SurfaceView(context); mSurfaceView.getHolder().addCallback(new SurfaceCallback()); addView(mSurfaceView); }
Example #16
Source File: ScanIsbnActivity.java From barterli_android with Apache License 2.0 | 5 votes |
/** * Stop scanning for a barcode, and release the camera */ private void stopScanningForBarcode() { if (mDecoderActivityHandler != null) { mDecoderActivityHandler.quitSynchronously(); mDecoderActivityHandler = null; } mCameraManager.closeDriver(); if (!mHasSurface) { final SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view); final SurfaceHolder surfaceHolder = surfaceView.getHolder(); surfaceHolder.removeCallback(this); } }
Example #17
Source File: CameraFragment.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
Preview(Context context) { super(context); mSurfaceView = new SurfaceView(context); addView(mSurfaceView); // Install a SurfaceHolder.Callback so we get notified when the // underlying surface is created and destroyed. mHolder = mSurfaceView.getHolder(); mHolder.addCallback(this); mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); }
Example #18
Source File: CameraSource.java From ETHWallet with GNU General Public License v3.0 | 5 votes |
/** * Opens the camera and starts sending preview frames to the underlying detector. The preview * frames are not displayed. * * @throws IOException if the camera's preview texture or display could not be initialized */ @RequiresPermission(Manifest.permission.CAMERA) public CameraSource start() throws IOException { synchronized (mCameraLock) { if (mCamera != null) { return this; } mCamera = createCamera(); // SurfaceTexture was introduced in Honeycomb (11), so if we are running and // old version of Android. fall back to use SurfaceView. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mDummySurfaceTexture = new SurfaceTexture(DUMMY_TEXTURE_NAME); mCamera.setPreviewTexture(mDummySurfaceTexture); } else { mDummySurfaceView = new SurfaceView(mContext); mCamera.setPreviewDisplay(mDummySurfaceView.getHolder()); } mCamera.startPreview(); mProcessingThread = new Thread(mFrameProcessor); mFrameProcessor.setActive(true); mProcessingThread.start(); } return this; }
Example #19
Source File: MainActivity.java From Smartlab with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); surfaceView = (SurfaceView) findViewById(R.id.surfaceView1); surfaceHolder = surfaceView.getHolder(); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); surfaceHolder.addCallback(this); }
Example #20
Source File: Camera2PreviewServerProvider.java From DeviceConnect-Android with MIT License | 5 votes |
/** * プレビューのサイズを View に収まるように調整します. * * @param isSwappedDimensions 縦横の幅をスワップする場合はtrue、それ以外はfalse */ private synchronized void adjustSurfaceView(boolean isSwappedDimensions) { if (mOverlayView == null) { return; } mHandler.post(() -> { HostMediaRecorder.PictureSize previewSize = mRecorder.getPreviewSize(); int cameraWidth = previewSize.getWidth(); int cameraHeight = previewSize.getHeight(); SurfaceView surfaceView = mOverlayView.findViewById(R.id.surface_view); Size changeSize; Size viewSize = new Size(mOverlayManager.getDisplayWidth(), mOverlayManager.getDisplayHeight()); if (isSwappedDimensions) { changeSize = calculateViewSize(cameraHeight, cameraWidth, viewSize); } else { changeSize = calculateViewSize(cameraWidth, cameraHeight, viewSize); } mOverlayManager.updateView(mOverlayView, 0, 0, changeSize.getWidth(), changeSize.getHeight()); surfaceView.getHolder().setFixedSize(previewSize.getWidth(), previewSize.getHeight()); TextView textView = mOverlayView.findViewById(R.id.text_view); textView.setVisibility(mCameraPreviewFlag ? View.VISIBLE : View.GONE); }); }
Example #21
Source File: ChatAdapter.java From CoolChat with Apache License 2.0 | 5 votes |
PeerVideoViewHolder(View itemView) { super(itemView); img_avatar = (ImageView) itemView.findViewById(R.id.img_avatar); text_name = (TextView) itemView.findViewById(R.id.text_name); surface_view = (SurfaceView) itemView.findViewById(R.id.surface_view); img_thumbnail = (ImageView) itemView.findViewById(R.id.img_thumbnail); imgbtn_play = (ImageButton) itemView.findViewById(R.id.imgbtn_play); surface_holder = surface_view.getHolder(); }
Example #22
Source File: Tutorial3Activity.java From OpenCV-AndroidSamples with MIT License | 5 votes |
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { Log.i(TAG, "called onCreate"); super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_tutorial3); mOpenCvCameraView = (Tutorial3View) findViewById(R.id.tutorial3_activity_java_surface_view); mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE); mOpenCvCameraView.setCvCameraViewListener(this); }
Example #23
Source File: CameraSourcePreview.java From Android-face-filters with Apache License 2.0 | 5 votes |
public CameraSourcePreview(Context context, AttributeSet attrs) { super(context, attrs); mContext = context; mStartRequested = false; mSurfaceAvailable = false; mSurfaceView = new SurfaceView(context); mSurfaceView.getHolder().addCallback(new SurfaceCallback()); addView(mSurfaceView); }
Example #24
Source File: PjCamera.java From pjsip-android with Apache License 2.0 | 5 votes |
public PjCamera(int idx, int w, int h, int fmt, int fps, long userData_, SurfaceView surface) { camIdx = idx; userData = userData_; param = new Param(); param.width = w; param.height = h; param.format = fmt; param.fps1000 = fps; SetSurfaceView(surface); }
Example #25
Source File: GPlayer.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.gplayer); mAudioManager = (AudioManager) getSystemService(Service.AUDIO_SERVICE); surfaceView = (SurfaceView) findViewById(R.id.gplayer_surfaceview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); mMediaPlayer = new MediaPlayer(); mMediaPlayer.setOnCompletionListener(this); mMediaPlayer.setOnErrorListener(this); mMediaPlayer.setOnInfoListener(this); mMediaPlayer.setOnPreparedListener(this); mMediaPlayer.setOnSeekCompleteListener(this); mMediaPlayer.setOnVideoSizeChangedListener(this); initControl(); Intent intent = getIntent(); playURI = intent.getStringExtra("playURI"); if (!TextUtils.isEmpty(playURI)) { setUri(playURI); } setTitle(intent); currentDisplay = getWindowManager().getDefaultDisplay(); registerBrocast(); }
Example #26
Source File: MediaPlayerDemo_Video.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
/** * * Called when the activity is first created. */ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.mediaplayer_2); mPreview = (SurfaceView) findViewById(R.id.surface); holder = mPreview.getHolder(); holder.addCallback(this); holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); extras = getIntent().getExtras(); }
Example #27
Source File: MultiVideoCallActivity.java From sealtalk-android with MIT License | 5 votes |
@Override public void onCallOutgoing(final RongCallSession callSession, SurfaceView localVideo) { super.onCallOutgoing(callSession, localVideo); this.callSession = callSession; RongCallClient.getInstance().setEnableLocalAudio(true); RongCallClient.getInstance().setEnableLocalVideo(true); localView = localVideo; onOutgoingCallRinging(); localViewContainer.addView(localView, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); localViewUserId = RongIMClient.getInstance().getCurrentUserId(); localView.setTag(localViewUserId); }
Example #28
Source File: SipService.java From CSipSimple with GNU General Public License v3.0 | 5 votes |
private void setCaptureVideoWindow(final SurfaceView window) { getExecutor().execute(new SipRunnable() { @Override protected void doRun() throws SameThreadException { pjService.setVideoAndroidCapturer(window); } }); }
Example #29
Source File: CameraSource.java From react-native-barcode-scanner-google with MIT License | 5 votes |
/** * Opens the camera and starts sending preview frames to the underlying detector. The preview * frames are not displayed. * * @throws IOException if the camera's preview texture or display could not be initialized */ @RequiresPermission(Manifest.permission.CAMERA) public CameraSource start() throws IOException { synchronized (mCameraLock) { if (mCamera != null) { return this; } mCamera = createCamera(); // SurfaceTexture was introduced in Honeycomb (11), so if we are running and // old version of Android. fall back to use SurfaceView. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mDummySurfaceTexture = new SurfaceTexture(DUMMY_TEXTURE_NAME); mCamera.setPreviewTexture(mDummySurfaceTexture); } else { mDummySurfaceView = new SurfaceView(mContext); mCamera.setPreviewDisplay(mDummySurfaceView.getHolder()); } mCamera.startPreview(); mProcessingThread = new Thread(mFrameProcessor); mFrameProcessor.setActive(true); mProcessingThread.start(); } return this; }
Example #30
Source File: MainActivity.java From augmentedreality with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //display setup stuff tv_alt = (TextView) findViewById(R.id.altitudeValue); tv_lat = (TextView) findViewById(R.id.latitudeValue); tv_long = (TextView) findViewById(R.id.longitudeValue); tv_head = (TextView) findViewById(R.id.headingValue); tv_pitch = (TextView) findViewById(R.id.pitchValue); tv_roll = (TextView) findViewById(R.id.rollValue); tv_x = (TextView) findViewById(R.id.xAxisValue); tv_y = (TextView) findViewById(R.id.yAxisValue); tv_z = (TextView) findViewById(R.id.zAxisValue); //we need the sensor manager and the gps manager, the //registration is all in onpause and onresume; mgr = (SensorManager) this.getSystemService(SENSOR_SERVICE); //orientation orient = mgr.getDefaultSensor(Sensor.TYPE_ORIENTATION); //acceleraometer accel = mgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); //gps location information myL = (LocationManager) getSystemService(Context.LOCATION_SERVICE); //setup the location listener. //all the camera preivew information inPreview = false; cameraPreview = (SurfaceView)findViewById(R.id.cameraPreview); previewHolder = cameraPreview.getHolder(); previewHolder.addCallback(this); previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); }