Android_多媒体

来源:互联网 发布:scratch live for mac 编辑:程序博客网 时间:2024/06/06 02:07
//无法改变屏幕方向
MainActivity.this.getRequestedOrientation()==ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
//竖屏
MainActivity.this.getRequestedOrientation()==ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
//横屏
MainActivity.this.getRequestedOrientation()==ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)

2.调用系统照相机
Intent imageCaptureIntent=newIntent(MediaStore.ACTION_IMAGE_CAPTURE);

3.录音机
//创建录音对象
mr=new MediaRecorder();
//麦克风进行录音
mr.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
//设置输出格式
mr.setAudioEncoder(MediaRecorder.OutputFormat.DEFAULT);
//设置编码格式
mr.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
//设置输出文件
mr.setOutputFile(file.getAbsolutePath());

4.手电筒
//实例化camera
m_Camera=Camera.open();
//得到Camera.parameters对象
Camera.Parametersparameters=m_Camera.getParameters();
//调用设置闪光灯
parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
//设置参数
m_Camera.setParameters(Parameters);
//开启闪光灯
m_Camera.startPreview();

5.语音识别
//通过intent传递语音识别的模式,开启语音
Intent intent=newIntent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
//语音模式和自由模式的语音识别
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
//提示语音开始
intent.putExtra(RecognizerIntent.EXTRA_PROMPT);
//开始语音识别
startActivityForResult(intent,VOICE_RECOGNITION_REQUEST_COdE);

0 0