English 中文(简体)
moto-raz
原标题:issue of recorder in moto-razr

I am a student doing my task of Android APPs. And I got a problem I can t fix.Pls give me some advice, thx. I want to have an activity of video recording, and I have done by using this code. Video recording with media recorder And here is my code, it work fine in other phone but it didnt work fine in moto-razr here are two video taking by HTC desire and MOTO razr. desire:http://youtu.be/suPF9Hk6iYk razr:http://youtu.be/wLvH7SXdcIs Can any one help me to fix my problem?

package video.pac;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.Display;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.Window;
import android.view.WindowManager;
public class video extends Activity{

private MediaRecorder recorder;
private Preview mPreview;

boolean flag=false; 
boolean startedRecording=false;
boolean stoppedRecording=false;
boolean key = false;

public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  requestWindowFeature(Window.FEATURE_NO_TITLE);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
      WindowManager.LayoutParams.FLAG_FULLSCREEN);
  WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);

  recorder = new MediaRecorder();
  recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
  recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
  recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
  recorder.setVideoSize(640,480);
  recorder.setVideoFrameRate(20);
  recorder.setVideoEncodingBitRate(3000000);
  recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
  recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
  //recorder.setMaxDuration(5000);
  mPreview = new Preview(video.this,recorder);
  setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  setContentView(mPreview);

 } 

private CountDownTimer mCountDownTimer = new CountDownTimer(9000, 1000) {

    public void onTick(long millisUntilFinished) {}

    public void onFinish() {

        recorder = null;
        System.out.println("stop");
        video.this.finish();
    }
};

class stopThread implements Runnable {   
    public void run() {  

          try {
              mCountDownTimer.start();  
               Thread.sleep(100);    
          } catch (InterruptedException e) {   
               Thread.currentThread().interrupt();   
          }   

    }   
}


class Preview extends SurfaceView implements SurfaceHolder.Callback{
  //Create objects for MediaRecorder and SurfaceHolder.
  SurfaceHolder mHolder;
  MediaRecorder tempRecorder;

  public Preview(Context context,MediaRecorder recorder) {
    super(context);
    tempRecorder=recorder;
    mHolder=getHolder();
    mHolder.addCallback(this);
    mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    // TODO Auto-generated constructor stub
  }

  public Surface getSurface(){
    return mHolder.getSurface();
  }

  public void surfaceCreated(SurfaceHolder holder){

    tempRecorder.setOutputFile("/sdcard/test" + ".3gpp");
    tempRecorder.setPreviewDisplay(mHolder.getSurface());
    try{
      tempRecorder.prepare();
      recorder.start();
     new Thread(new stopThread()).start();

      System.out.println("start");
    } catch (Exception e) {
      tempRecorder.release();
      tempRecorder = null;
    }
  }

  public void surfaceDestroyed(SurfaceHolder holder) {
    if(tempRecorder!=null){
      tempRecorder.stop();
      tempRecorder.release();
      tempRecorder = null;
      System.out.println("release");
    }
  }

  public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {}
}   
}
问题回答

我认为,这是一个安全问题:

你们需要打上纪录片,否则,一些装置会认为这违反了安全,无法在屏幕上显示你的捕获/审查。 在你的记录编制中添加这一点:

 .
 .
 recorder.setPreviewDisplay(mHolder.getSurface());
 .
 .




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签