views:

37

answers:

1

Hello people,

well im really new to the delphi world.

Right now im using the TMediaPlayer to record some sound and save those. I made a click event for the record button in the TMediaPlayer which executes a SaveFileDialog. The user should type in some filename he would like to save and then after recording the .wav file he can click on the stop button and it will save his recorded .wav file.

Actually it dont event create a file.

I will show some important code parts of my delphi code

if Button = TMPBtnType.btRecord then
begin
SaveDialogSpeichern.Execute;
MediaPlayerSound.FileName := SaveDialogSpeichern.FileName;
MediaPlayerSound.StartRecording;

end

and those for save:

  MediaPlayerSound.Stop;
  MediaPlayerSound.Save;

I cant use the bass.dll , so i would like to make this with the TMediaPlayer if there is a possible way

+1  A: 

I found a solution for my problem. It seems that the TMediaPlayer do not support creating sound files either Recording sound files.

There is a way to use the WinApi (using mmSystem;)

i used this code:

    mciSendString(PChar('OPEN NEW TYPE WAVEAUDIO ALIAS mysound'), nil, 0,
    Handle);
 mciSendString(PChar('SET mysound TIME FORMAT MS ' +     
   'BITSPERSAMPLE 8 ' +                
   'CHANNELS 1 ' +                     
   'SAMPLESPERSEC 8000 ' +             
   'BYTESPERSEC 8000'),                
   nil, 0, Handle);
 mciSendString(PChar('RECORD mysound'), nil, 0, Handle);
mciSendString(PChar('SAVE mysound "' + SaveDialogSpeichern.FileName+'"' ), nil, 0,
    Handle);
mciSendString(PChar('CLOSE mysound'), nil, 0, Handle) 

hope this will help anyone with the same problem

darkdog