unit Unit2; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,FMX.Media.Android,Androidapi.JNI.Media, FMX.Controls.Presentation, FMX.StdCtrls,System.IOUtils,Androidapi.JNI.GraphicsContentViewText, Androidapi.JNI.Provider, Androidapi.JNI.App, Androidapi.JNI.Net, Androidapi.JNIBridge, FMX.Media, Androidapi.JNI.JavaTypes, Androidapi.JNI.Os,Androidapi.Helpers; type TForm2 = class(TForm) Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } texture : JSurfaceTexture; surface: JSurface; recorder: JMediaRecorder; end; var Form2: TForm2; implementation {$R *.fmx} procedure TForm2.Button1Click(Sender: TObject); var
FILENAME:STRING; begin texture := TJSurfaceTexture.JavaClass.init(1); surface := TJSurface.JavaClass.init(texture); recorder := TJMediaRecorder.Create(); recorder.setPreviewDisplay(surface); recorder.setAudioSource(TJMediaRecorder_AudioSource.JavaClass.CAMCORDER); recorder.setVideoSource(TJMediaRecorder_VideoSource.JavaClass.CAMERA); recorder.setOutputFormat(TJMediaRecorder_OutputFormat.JavaClass.MPEG_4); recorder.setAudioEncoder(TJMediaRecorder_AudioEncoder.JavaClass.DEFAULT); recorder.setVideoEncoder(TJMediaRecorder_VideoEncoder.JavaClass.H264); recorder.setMaxDuration(1800000); // 30 minutes recorder.setVideoSize(320, 240); recorder.setVideoFrameRate(15); filename:=TPath.GetSharedCameraPath+'/abc0002.mp4'; recorder.setOutputFile(StringToJString(FILENAME)); recorder.prepare(); recorder.start(); end; procedure TForm2.Button2Click(Sender: TObject); begin recorder.stop; end; end.