Solved

Record from mic using Delphi Mediaplayer

Posted on 2006-11-29
6
2,110 Views
Last Modified: 2008-01-09
I'm trying to record from the mic using the Delphi Mediaplayer component.

All existing answers to this question point to a link called:

http://www.bhnet.com.br/~simonet/howtoprojs.htm

which does not work!

Any suggestions/code examples?

Thanks

JonathanH13
0
Comment
Question by:JonathanH13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 18038412
Do you first have to create a blank .wav file and link it to the mediaplayer.
Then when the application starts, mediaplayer.open to open the file, then just press the record button and talk?
Never used it so Im just guessing.
Might even have to move back to the beginning of the file once finished recording.
0
 

Author Comment

by:JonathanH13
ID: 18038545
Yeah, that's the idea, but it's not so straightforward. What I have so far:

procedure TForm1.Button1Click(Sender: TObject);
begin
    Timer1.Enabled:=True;

    MediaPlayer1.FileName := 'c:\Test.Wav';
    MediaPlayer1.Open;
    MediaPlayer1.StartRecording;

end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
 MediaPlayer1.Stop;
 Label1.Caption:='End';
end;

But this does not work, and I'm not sure why...
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 18039338
Yeah Im not getting it to work either.
Must be something really obvious Im missing but this isnt something I normally play around with.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:Meldrachaun
ID: 18040389
Is this the know bug with TMediaPlayer?

http://qc.borland.com/wc/qcmain.aspx?d=5475
http://bdn.borland.com/article/16427

One thing you might try.  I haven't used it, but it looks like there's a JEDI version of Apple's QuickTime components.  You might be able to record with that...

http://www.delphi-jedi.org/
0
 
LVL 9

Accepted Solution

by:
bernani earned 300 total points
ID: 18059709

Hi,

You can't record in Delphi using MP.Startrecording but you can assign a procedure for the MP record button to do it

Use .... MMSystem;

...

// recording .... Stereo 44KHz 16Bits
procedure TForm1.btnRecordClick(Sender: TObject);
begin
mciSendString('OPEN NEW TYPE WAVEAUDIO ALIAS mySound',nil,0,Handle);
mciSendString('SET mySound ' +
                   'TIME FORMAT MS ' +
                   'BITSPERSAMPLE 16 ' +
                   'CHANNELS 2 ' +
                   'SAMPLESPERSEC 44100 ' +
                   'BYTESPERSEC 176400 ' +
                   'ALIGNMENT 4',
                   nil,0,handle);
mciSendString('RECORD mySound',nil,0,Handle);
end;

// stop recording and save as "The Name of the file recorded.wav".

procedure TForm1.btnStopandSaveClick(Sender: TObject);
begin
mciSendString('STOP mySound',nil,0,Handle);
mciSendString('SAVE mySound "The Name of the file recorded.wav"',nil,0,Handle);
mciSendString('CLOSE mySound',nil,0,Handle);
end;

Hope this can help.





0
 

Author Comment

by:JonathanH13
ID: 18067485
bernani,

Yeah, that works. Thanks!

I found a way of getting around the problem by simply copying a blank audio file, in order to create a new file for recording:

FromFile := TFileStream.Create('Audio\Blank.wav', fmOpenRead);
    ToFile := TFileStream.Create('Audio\'+NameString+'.wav', fmCreate);
    ToFile.CopyFrom(FromFile, FromFile.Size);
    ToFile.Free;
    FromFile.Free;

Thanks Meldrachaun  for the useful overview, but I could not get the workaround in http://qc.borland.com/wc/qcmain.aspx?d=5475 to function properly.

Cheers,
JonathanH13
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Print Graphic and Text to Epson TM-T88v 12 478
Firemonkey BASS_Init into a thread 17 57
IP without any Dots 1 60
Connect to SQL 2008 r2 server over the Internet 4 23
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question