zoukankan      html  css  js  c++  java
  • delphi android 录像(使用了JMediaRecorder,MediaRecorder的使用方法可参考网上java的相关说明)

    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.
    复制代码
     
    https://www.cnblogs.com/qiufeng2014/p/4809144.html
  • 相关阅读:
    因为数据库无法大写循环所有要使用shell
    mysql动态扩容调研
    MySQL扩容
    数据库死锁及解决死锁问题
    SQL数据库常见故障及解决方法
    通过Ajax方式上传文件(input file),使用FormData进行Ajax请求
    Ajax方式上传文件
    高并发解决方案--负载均衡
    对TCP/IP协议的深入浅出总结
    常用的php开发工具有哪些?
  • 原文地址:https://www.cnblogs.com/findumars/p/5704525.html
Copyright © 2011-2022 走看看