please help me!

On Jun 22, 9:45 am, cindy <ypu01...@yahoo.com> wrote:
> I have tried 1.5 video API. I could not make it work.It even can't do
> preview.
>
>  following is my code:
> private boolean initializeVideo() {
>         Log.v(TAG, "initializeVideo");
>
>         if(Common.mRecordedVideo!=null && Common.mRecordedVideo.exists())
>                 Common.mRecordedVideo.delete();
>         File sDir = Environment.getExternalStorageDirectory();
>         String baseDir = sDir + Common.BASE_DIR;
>         File sampleDir=new File(baseDir);
>         if(!sampleDir.canWrite()) // Workaround for broken sdcard
> support on the device.
>             sampleDir = new File("/sdcard/sdcard");
>
>         try
>         {
>             Common.mRecordedVideo = File.createTempFile(PREFIX,
> EXTENSION, sampleDir);
>         }
>         catch(IOException e)
>         {
>             AlertDialog.Builder ab = new AlertDialog.Builder
> (VideoRecord.this);
>             ab.setTitle("Error");
>             ab.setMessage(" can't write audio data to storage");
>             ab.setIcon(R.drawable.error);
>             ab.setNeutralButton("Close", new
> DialogInterface.OnClickListener()
>             {
>                 public void onClick(DialogInterface dialog, int
> whichButton)
>                 {
>                 }
>             });
>             ab.show();
>             return false;
>         }
>
>         Intent intent = getIntent();
>         releaseMediaRecorder();
>
>         if (mSurfaceHolder == null) {
>             Log.v(TAG, "SurfaceHolder is null");
>             return false;
>         }
>
>         mMediaRecorder = new MediaRecorder();
>
>          mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
>
>         mMediaRecorder.setVideoSource
> (MediaRecorder.VideoSource.CAMERA);
>         mMediaRecorder.setOutputFormat
> (MediaRecorder.OutputFormat.THREE_GPP);
>
>         mMediaRecorder.setMaxDuration(MAX_RECORDING_DURATION_MS);
>         mMediaRecorder.setOutputFile
> (Common.mRecordedVideo.getAbsolutePath());
>
>         // Use the same frame rate for both, since internally
>         // if the frame rate is too large, it can cause camera to
> become
>         // unstable. We need to fix the MediaRecorder to disable the
> support
>         // of setting frame rate for now.
>         mMediaRecorder.setVideoFrameRate(20);
>        mMediaRecorder.setVideoSize(352,288);
>
>         mMediaRecorder.setVideoEncoder
> (MediaRecorder.VideoEncoder.H263);
>
>         mMediaRecorder.setPreviewDisplay(mSurfaceHolder.getSurface());
>
>         try {
>             mMediaRecorder.prepare();
>         } catch (IOException exception) {
>             Log.e(TAG, "prepare failed for " );
>             releaseMediaRecorder();
>             // TODO: add more exception handling logic here
>             return false;
>         }
>         mMediaRecorderRecording = false;
>
>         return true;
>     }
>
>  private void startVideoRecording() {
>         Log.v(TAG, "startVideoRecording");
>         if (!mMediaRecorderRecording)
>         {
>                 // Check mMediaRecorder to see whether it is initialized or
> not.
>             if (mMediaRecorder == null && initializeVideo() ==
> false )
>             {
>                 Log.e(TAG, "Initialize video (MediaRecorder)
> failed.");
>                 return;
>             }
>             try
>             {
>                 mMediaRecorder.setOnErrorListener(this);
>                 mMediaRecorder.setOnInfoListener(this);
>                 mMediaRecorder.start();   // Recording is now started
>             } catch (RuntimeException e) {
>                 Log.e(TAG, "Could not start media recorder. ", e);
>                 return;
>             }
>             mMediaRecorderRecording = true;
>             mRecordingStartTime = SystemClock.uptimeMillis();
>             updateRecordingIndicator(true);
>             mRecordingTimeView.setText("");
>             mRecordingTimeView.setVisibility(View.VISIBLE);
>             mHandler.sendEmptyMessage(UPDATE_RECORD_TIME);
>             setScreenTimeoutInfinite();
>         }
>     }
>
> On Jun 21, 6:05 pm, cindy <ypu01...@yahoo.com> wrote:
>
> > do you have any simple sample code for video recording?
>
> > Thanks!
>
> > Cindy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to