程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> delphi android 錄像,delphiandroid

delphi android 錄像,delphiandroid

編輯:Delphi

delphi android 錄像,delphiandroid


delphi xe系列自帶的控件都無法保存錄像,經網友幫忙,昨天終於實現了錄像功能(但有個問題是錄像時無畫面顯示),程序主要使用了JMediaRecorder,MediaRecorder的使用方法可參考網上java的相關說明,下面代碼是可以正常錄像的:

unit Unit8;

interface

uses
 System.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;

type
  TForm8 = class(TForm)
    Button3: TButton;
    Button4: TButton;
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private declarations }
     texture : JSurfaceTexture;
     surface: JSurface;
     recorder: JMediaRecorder;
  public
    { Public declarations }
  end;

var
  Form8: TForm8;

implementation

{$R *.fmx}

procedure TForm8.Button3Click(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.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); // 30 minutes
  recorder.setVideoSize(320, 240);
  recorder.setVideoFrameRate(15);
   filename:=TPath.GetSharedCameraPath+'/abc0002.mp4';
  recorder.setOutputFile(StringToJString(FILENAME));
  recorder.prepare();
  recorder.start();
end;

procedure TForm8.Button4Click(Sender: TObject);
begin
   recorder.stop;
end;

end.

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved