Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hello there, I am trying to use

Status
Not open for further replies.

nicasa

Programmer
Feb 3, 2003
54
ES
Hello there,

I am trying to use a TMediaPlayer object to record sounds from an application, but without success. What I do not get is how to create the .wav file. Here is a snippet of code:-

void __fastcall TForm1::FormCreate(TObject *Sender)
{
MediaPlayer1->DeviceType = dtAutoSelect;
MediaPlayer1->FileName = "C:\\GUIS\\Tmedia\\TEST.wav";
MediaPlayer1->Open();
}

How can the file exist before you have created it ?

What I have tried to do is open a file called test.wav
using fopen() and assign that to MediaPlayer1->FileName
and try to record on to that. Somehow this does not feel right.

How can I use a TMedia object to CREATE a new .wav file for recording sounds ?

THanks in advance,

Steven matthews




 
Hi this is the part of my program. I hope it will help you. This is not include recording but there are others functions which are available in MediaPlayer I hope to help you Bye


#include <vcl.h>
#pragma hdrstop

#include &quot;Main.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link &quot;CGAUGES&quot;
#pragma resource &quot;*.dfm&quot;
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::TimerTimer(TObject *Sender)
{
if (MediaPlayer->Mode==mpPlaying)
{
Pasek->Progress=MediaPlayer->Position*100/MediaPlayer->Length;
}
if (MediaPlayer->Mode==mpStopped)
{
Timer->Enabled=false;
Pasek->Progress=0;
MediaPlayer->Rewind();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
if (OpenDialog->Execute())
{
MediaPlayer->FileName=OpenDialog->FileName;
MediaPlayer->Open();
Button1->Enabled=true;
Button2->Enabled=true;
Button3->Enabled=true;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
MediaPlayer->Play();
Timer->Enabled=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
MediaPlayer->Stop();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
MediaPlayer->Pause();
}
 
Saves the currently loaded medium to the file specified in the FileName property.

void __fastcall Save(void);

See the help files for TMediaPlayer.

tomcruz.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top