Up vote 0 down vote favorite share g+ share fb share tw.
I have a samsung galaxy tab that was running on android 2.2. I developed an simple program to record the audio and video seperately. It was working fine on my galaxy tab. But, everything changed after I upgraded it to android 2.3.3.
My code stopped working from that moment on. Here is my code that is showing this unexpected(for me :)) behaviour: // import statements public class CameraPreview extends Activity implements SurfaceHolder. Callback { Camera camera; SurfaceView surfaceView; SurfaceHolder surfaceHolder; boolean previewing = false; LayoutInflater controlInflater = null; Button recordButton; /** Called when the activity is first created.
*/ public void onCreate(Bundle savedInstanceState) { super. OnCreate(savedInstanceState); setContentView(R.layout. Camera); setRequestedOrientation(ActivityInfo.
SCREEN_ORIENTATION_LANDSCAPE); getWindow(). SetFormat(PixelFormat. UNKNOWN); surfaceView = (SurfaceView) findViewById(R.id.
Camerapreview); surfaceHolder = surfaceView.getHolder(); surfaceHolder. AddCallback(this); surfaceHolder. SetType(SurfaceHolder.
SURFACE_TYPE_PUSH_BUFFERS); controlInflater = LayoutInflater. From(getBaseContext()); View viewControl = controlInflater. Inflate(R.layout.
Control, null); LayoutParams layoutParamsControl = new LayoutParams( LayoutParams. FILL_PARENT, LayoutParams. FILL_PARENT); this.
AddContentView(viewControl, layoutParamsControl); recordButton = (Button)viewControl. FindViewById(R.id. Start_recording); recordButton.
SetOnClickListener(new View.OnClickListener() { public void onClick(View v) { startRecording(); } }); } public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { if (previewing) { camera.stopPreview(); previewing = false; } if (camera! = null) { try { camera. SetPreviewDisplay(surfaceHolder); camera.startPreview(); previewing = true; } catch (IOException e) { e.printStackTrace(); } } } public void surfaceCreated(SurfaceHolder holder) { camera = Camera.open(); } public void surfaceDestroyed(SurfaceHolder holder) { camera.stopPreview(); camera.release(); camera = null; previewing = false; } private void startRecording() { try { stopPreview(); Thread video = new Thread(new Runnable() { public void run() { videoRecorder = new MediaRecorder(); videoRecorder.
SetPreviewDisplay(surfaceView.getHolder().getSurface()); videoRecorder. SetVideoSource(MediaRecorder.VideoSource. DEFAULT); videoRecorder.
SetOutputFormat(2); videoRecorder. SetVideoEncodingBitRate(56 * 8 * 1024); videoRecorder. SetVideoSize(176, 144); videoRecorder.
SetVideoFrameRate(12); videoRecorder. SetVideoEncoder(MediaRecorder.VideoEncoder. MPEG_4_SP); videoRecorder.
SetOutputFile("/sdcard/video. M4e"); try { videoRecorder.prepare(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } videoRecorder.start(); } }); video.start(); Thread audio = new Thread(new Runnable() { public void run() { audioRecorder = new MediaRecorder(); audioRecorder. SetAudioSource(MediaRecorder.AudioSource.
MIC); audioRecorder. SetOutputFormat(MediaRecorder.OutputFormat. RAW_AMR); audioRecorder.
SetAudioEncoder(MediaRecorder.AudioEncoder. AMR_NB); audioRecorder. SetOutputFile("/sdcard/audio.
Amr"); try { audioRecorder.prepare(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } audioRecorder.start(); } }); audio.start(); } catch (Exception e) { Log. E("streamer", "Unable to start recording", e); } } private void stopPreview() { if (camera == null) { throw new RuntimeException(); } camera.stopPreview(); camera.release(); camera = null; } } Following is the log output: PID TAG MESSAGE D 75 CameraHardwareSec MemoryHeapBase(fd(27), size(5760128), width(800), height(600)) E 75 AuthorDriver Command 13 completed with error -17 E 7169 MediaRecorder prepare failed: -17 W 7169 System. Err java.io.
IOException: prepare failed. W 7169 System. Err at android.media.MediaRecorder.
_prepare(Native Method) W 7169 System. Err at android.media.MediaRecorder. Prepare(MediaRecorder.
Java:592) W 7169 System. Err at com.video.streamer.view. CameraPreview$2.
Run(CameraPreview. Java:121) W 7169 System. Err at java.lang.Thread.
Run(Thread. Java:1019) E 7169 MediaRecorder start called in an invalid state: 0 W 7169 dalvikvm threadid=10: thread exiting with uncaught exception (group=0x40015578) E 7169 AndroidRuntime FATAL EXCEPTION: Thread-11 E 7169 AndroidRuntime java.lang. IllegalStateException E 7169 AndroidRuntime at android.media.MediaRecorder.
Start(Native Method) E 7169 AndroidRuntime at com.video.streamer.view. CameraPreview$2. Run(CameraPreview.
Java:127) E 7169 AndroidRuntime at java.lang.Thread. Run(Thread. Java:1019) W 118 ActivityManager Force finishing activity com.video.streamer.
View/. CameraPreview Following are my XML files used for layout purpose. Camera.
Xml control. Xml I used the following permissions on AndroidManifest. Xml A video recording example I got from roman10 guys blog: Android Video Recording API–Illustrated with an Example was also working fine with my android 2.2. But, that also stopped working as a result of my upgrade.
Is there anything I am missing when recording video with android 2.3.3. How can I solve this problem? Android audio-recording mediarecorder video-recording android-mediarecorder link|improve this question asked Feb 3 at 1:44Jomoos1,455215 85% accept rate.
I have the same problem. – lukewm Feb 6 at 21:47.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.