surfaceholder

How to attach MediaPlayer with SurfaceView in android?

只愿长相守 提交于 2019-12-17 22:24:48
问题 I'm building video player with android media player object. i'm able to hear the audio but the video does not appear on surfaceView. here is my code public class PlayerActivity extends Activity implements SurfaceHolder.Callback { String path; private MediaPlayer mp; private SurfaceView mPreview; private SurfaceHolder holder; boolean pausing = false; public static String filepath; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R

.setPreviewDisplay(holder) throwing null pointer exception

喜你入骨 提交于 2019-12-14 02:12:51
问题 I am developing a custom camera application.Given below is my Activity class. public class MyCustomCam extends Activity { private Camera mCamera; private CameraPreview mPreview; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mCamera = getCameraInstance(); mPreview = new CameraPreview(this, mCamera); FrameLayout preview = (FrameLayout) findViewById(R.id.camera

java.lang.IllegalArgumentException:at android.view.Surface.unlockCanvasAndPost(Native Method)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 05:39:02
问题 I've searched about this problem for two days. I know that this is caused by some silly mistake but i'm unable to find that thing. It would be great, if someone helps me. Here is snippet private void draw() { final SurfaceHolder holder = getSurfaceHolder(); Canvas c = holder.lockCanvas();; try { update(c); updateText(c); //These are the effects like snowing or bouncing } finally { if (c != null) holder.unlockCanvasAndPost(c); //This is line no. 151 } mHandler.removeCallbacks(drawRunner); if

“Error 1” occurring during camera overlay in Android

▼魔方 西西 提交于 2019-12-12 05:16:14
问题 I have created an Activity that has a SurfaceView and a SurfaceHolder in order to create a Camera overlay. For some reason, I am getting the following in ADB: 04-08 10:54:06.747: E/Camera(1152): Error 1 . I am able to take a picture, but I cannot get any kind of preview. Here is the code I am using: public class MyActivity extends Activity implements SurfaceHolder.Callback, Camera.ShutterCallback, Camera.PictureCallback, OnClickListener { private Camera mCamera; private SurfaceView

Getting image data continuously from camera, SurfaceView or SurfaceHolder

女生的网名这么多〃 提交于 2019-12-11 03:28:35
问题 So I have this camera preview set up with Camera , SurfaceView and SurfaceHolder . I have also an ImageView where I will be putting a modified version of the camera image and I want this to update lets say once every second. All code is ready and already working when I load images from "res" but I have a really hard time reading the image data from the camera. I've tried following already: Creating an intent for MediaStore.ACTION_IMAGE_CAPTURE and starting an onActivityResult getting a small

What is the use of calling SurfaceHolder.setFixedSize()?

自闭症网瘾萝莉.ら 提交于 2019-12-11 00:39:51
问题 I have similar code to many examples floating around the net: mSurfaceHolder = mVideoSurface.getHolder(); mSurfaceHolder.addCallback(this); mSurfaceHolder.setFormat(PixelFormat.TRANSPARENT); mSurfaceHolder.setFixedSize(20, 10); Then in the callbacks I have: @Override public void surfaceCreated(SurfaceHolder holder) { Log.d(TAG, "SurfaceCreated"); mSurfaceHolder.setFixedSize(20, 10); } @Override public void surfaceChanged( SurfaceHolder holder, int format, int width, int height ) { Log.d(TAG,

Change size of Android custom SurfaceView

一笑奈何 提交于 2019-12-10 10:15:58
问题 I'm trying to create a 2D game engine for an Android app. I've followed this tutorial, which works fine for creating a full screen display, but I don't want that. I want to make my view take the top 2/3 (or whatever) of the screen, and fill the bottom third with standard Android widgets (buttons, text entry, etc.). I cannot get this to work. The best I can get is a blank white screen. I've tried many permutations, including using an outer LinerLayout, then embedding the custom SurfaceView

Android Camera - app passed NULL surface

僤鯓⒐⒋嵵緔 提交于 2019-12-10 01:14:33
问题 Whenever I run the cam_thread I get the error "app passed NULL surface". This code supposedly works on the HTC Incredible 1. I've reconfigured it slightly to run on a droid x. However I still get this error. public class Android_Activity extends Activity { Main_thread simulator; ToggleButton togglebutton; EditText ip_text; SensorManager sm = null; SurfaceView view; Sensors_thread the_sensors=null; String IP_address; Android_Activity the_app; @Override protected void onCreate(Bundle

LiveWallpaper with SurfaceHolder.lockCanvas(Rect dirty)

Deadly 提交于 2019-12-07 06:10:38
问题 I would like to ask about a problem that has been addressed here once or twice, but none of information I found could help me overcome the problem I faced a few days ago. I want to make a live wallpaper for android using canvases - it is not graphically complicated enough to require OpenGL. For simplicity assume it consists of solid background and two smaller rectangles. Drawing consists of three separate stages (in single thread): backgroundDraw() requests entire canvas lock and draws on it

Can't set video quality for media recorder.video produces flickering video

不想你离开。 提交于 2019-12-06 03:27:33
问题 mMediaRecorder = new MediaRecorder(); // Step 1: Unlock and set camera to MediaRecorder mCamera.unlock(); mMediaRecorder.setCamera(mCamera); // Step 2: Set sources // activate this for recording with sound\ mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); mMediaRecorder.setVideoSize(getMaxSupportedVideoSize().width,getMaxSupportedVideoSize().height);