RAD Studio XE8 Cross-platform for recording and recording functions in the app

Source: Internet
Author: User

First, open Rad Studio XE8, new project, add Components MediaPlayer, cameracomponent and some buttons, from top to next for Button1, 2, 3, 4, 5, 6, 7, 8;

Second, in the header file. h add:#include <fmx. Media.hpp>, and

__published:void __fastcall GetImage ();

Private

Taudiocapturedevice *microphone; Declaring a microphone

String FileName;

Third, write the code in each button:

Note that there is #include <System.IOUtils.hpp>in the. cpp file, and the remaining code is:

__fastcall Tform1::tform1 (tcomponent* owner) : Tform (owner)

{//Turn on the microphone device, locate the storage path

microphone=tcapturedevicemanager::current->defaultaudiocapturedevice;

Filename=includetrailingpathdelimiter (System::ioutils::tpath::gettemppath ()) + "MY.CAF";

}

void __fastcall Tform1::getimage () {//recognition camera recorded image

Cameracomponent1->samplebuffertobitmap (this->image1->bitmap,true);

}

void __fastcall Tform1::cameracomponent1samplebufferready (tobject *sender, const tmediatime ATime)

{

Tthread::synchronize (Tthread::currentthread,getimage); Calling the GetImage method

}

void __fastcall Tform1::button1click (tobject *sender)//Start recording

{

this->cameracomponent1->active=true;

}

void __fastcall Tform1::button2click (tobject *sender)//Stop Recording

{

this->cameracomponent1->active=false;

}

void __fastcall Tform1::button3click (tobject *sender)//Open Flash

{

this->cameracomponent1->torchmode=ttorchmode::modeon;

}

void __fastcall Tform1::button4click (tobject *sender)//Turn off Flash

{

this->cameracomponent1->torchmode=ttorchmode::modeoff;

}

void __fastcall Tform1::button5click (tobject *sender)//Start playback

{

this->mediaplayer1->filename=filename;

This->mediaplayer1->play ();

}

void __fastcall Tform1::button6click (tobject *sender)//Start recording

{

this->microphone->filename=filename; Get the storage directory for recordings

this->edit1->text=filename;

This->microphone->startcapture ();

}

void __fastcall Tform1::button7click (tobject *sender)//Stop playback

{

This->mediaplayer1->stop ();

}

void __fastcall Tform1::button8click (tobject *sender)//Stop Recording

{

This->microphone->stopcapture ();

}

Third, click on the Project.exe, right-click option, tick a few options to enable the Android platform to support media playback and recording, read and write user directory features:

Four, will realize the platform for Android, click to run, after installation on the phone to open, click Start Recording, you can see the edit box shows the table of contents, stop recording after the playback (the sound may be small, remember to adjust the volume), the video can switch the flash.

RAD Studio XE8 Cross-platform for recording and recording functions in the app

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.