Перейти к содержанию
Fire Monkey от А до Я

GregGirya

Пользователи
  • Постов

    0
  • Зарегистрирован

  • Посещение

Активность репутации

  1. Like
    GregGirya отреагировална Rusland в Как записать видео на Андроиде?   
    Вот нашел код для записи видео (проверил - работает):
    unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, Androidapi.JNI.GraphicsContentViewText, System.Messaging, // TMessageManager FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls, FMX.Controls.Presentation; type TForm1 = class(TForm) BtnRecord: TButton; Label1: TLabel; procedure BtnRecordClick(Sender: TObject); private { Private declarations } procedure HandleActivityMessage(const Sender: TObject; const M: TMessage); function OnActivityResult(RequestCode, ResultCode: Integer; Data: JIntent): Boolean; public { Public declarations } FMessageSubscriptionID:integer; end; var Form1: TForm1; const RECORD_VIDEO = 9; implementation {$R *.fmx} uses System.IOUtils, Androidapi.JNI.Provider, Androidapi.JNI.App, Androidapi.JNI.Net, Androidapi.JNIBridge, Androidapi.Helpers, Androidapi.JNI.JavaTypes, Androidapi.JNI.Os; procedure TForm1.BtnRecordClick(Sender: TObject); var VideoIntent: JIntent; videoUri: Jnet_Uri; AFile: JFile; FileName: TFileName; begin FMessageSubscriptionID := TMessageManager.DefaultManager.SubscribeToMessage( TMessageResultNotification, HandleActivityMessage); VideoIntent := TJIntent.JavaClass.init( TJMediaStore.JavaClass.ACTION_VIDEO_CAPTURE ); if ( VideoIntent.resolveActivity( SharedActivityContext.getPackageManager() ) <> nil) then begin FileName := TPath.Combine( TPath.GetSharedDocumentsPath, 'recording.mp4'); // см. /storage/sdcard0/Documents AFile:=TJFile.JavaClass.init( StringToJString(FileName)); videoUri:=TJnet_Uri.JavaClass.fromFile(AFile); VideoIntent.putExtra( TJMediaStore.JavaClass.EXTRA_OUTPUT, TJParcelable.Wrap((videoUri as ILocalObject).GetObjectID)); SharedActivity.startActivityForResult(VideoIntent, RECORD_VIDEO); end; end; procedure TForm1.HandleActivityMessage(const Sender: TObject; const M: TMessage); begin if M is TMessageResultNotification then OnActivityResult( TMessageResultNotification(M).RequestCode, TMessageResultNotification(M).ResultCode, TMessageResultNotification(M).Value); end; function TForm1.OnActivityResult(RequestCode, ResultCode: Integer; Data: JIntent): Boolean; begin Result := False; TMessageManager.DefaultManager.Unsubscribe( TMessageResultNotification, FMessageSubscriptionID); FMessageSubscriptionID := 0; if RequestCode = RECORD_VIDEO then begin if ResultCode = TJActivity.JavaClass.RESULT_OK then begin TThread.Queue(nil, procedure begin Label1.Text:='recording completed'; Invalidate; end); end; end; end; end. Пишет стандартной программой и сохраняет под названием recording.mp4
    Если нужно просто писать видео, то подойдет. 
×
×
  • Создать...