Delphi XE series of control can not save video, after the help of netizens, yesterday finally realized the video function (but there is a problem is the video display without screen), the program is mainly used Jmediarecorder, The use of Mediarecorder can refer to the Web-based Java instructions, the following code is capable of normal recording:
UnitUnit8;Interfaceusessystem.sysutils, System.types, System.uitypes, system.classes, System.variants, Androidapi.helpers, 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;typeTFORM8=class(tform) Button3:tbutton; Button4:tbutton; procedureButton3click (Sender:tobject); procedureButton4click (Sender:tobject); Private {Private Declarations}texture:jsurfacetexture; Surface:jsurface; Recorder:jmediarecorder; Public {Public Declarations} End;varFORM8:TFORM8;Implementation{$R *.FMX}procedureTform8.button3click (Sender:tobject); VAR filename:string;beginTexture:= TJSurfaceTexture.JavaClass.init (1); Surface:=TJSurface.JavaClass.init (texture); Recorder:= Tjmediarecorder.Create(); Recorder.setpreviewdisplay (surface); Recorder.setaudiosource (TJMediaRecorder_AudioSource.JavaClass.MIC); 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);//minutesRecorder.setvideosize ( the, -); Recorder.setvideoframerate ( the); FileName:=tpath.getsharedcamerapath+'/abc0002.mp4'; Recorder.setoutputfile (stringtojstring (FILENAME)); Recorder.prepare (); Recorder.start ();End;procedureTform8.button4click (sender:tobject);beginRecorder.stop;End;End.
Delphi Android Video