## Start playing a WAV file from a specified position

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

### Start playing a WAV file from a specified position

Could you please give me some advice on your TStockAudioPlayer component? I need to start playing a WAV file from a specified position, not from the beginning. Is this possible?
wilhelms@intekom.co.za
Active Member

Posts: 7
Joined: May 21st, 2007, 11:54 am

1. set Paused property to True
2. call PlayFile method
3. set Position property
4. set Paused property to False
Kambiz

Kambiz

Posts: 2430
Joined: March 7th, 2003, 7:10 pm

Thanks, but I can't get this to work. The documentation say that Position is read only.

I tried adding this code to a new button's OnClick event handler in your SndRcrdr demo project:

StockAudioPlayer.Paused := true;
StockAudioPlayer.PlayFile(WaveFile.Caption);
StockAudioPlayer.Position := 5000;
StockAudioPlayer.Paused := false;

But it just starts playing the WAV from the start.
wilhelms@intekom.co.za
Active Member

Posts: 7
Joined: May 21st, 2007, 11:54 am

I forgot to mention: The wav is more than 5000 milliseconds long.

Regards

Wilhelm
wilhelms@intekom.co.za
Active Member

Posts: 7
Joined: May 21st, 2007, 11:54 am

I was forgotten that recently I changed the behavior, sorry.

Code: Select all
StockAudioPlayer1.Position := 5000;StockAudioPlayer1.PlayFile('test.wav');

The previous method didn't work because of a bug.
Kambiz

Kambiz

Posts: 2430
Joined: March 7th, 2003, 7:10 pm

### Sound interference

This does play the wav from the specified position, but unfortunately with interferance in the sound. I have attached a zip file including my modifications to your demo code. I will appreciate if you are able to have a look at this.

Regards

Wilhelm
Attachments
SndRcrdr.zip
wilhelms@intekom.co.za
Active Member

Posts: 7
Joined: May 21st, 2007, 11:54 am

Your sample works as expected with no problem.
What's version of your Wave Audio package?
Kambiz

Kambiz

Posts: 2430
Joined: March 7th, 2003, 7:10 pm

It is v1.82, compiled in Delphi 7.0, run on Win XP.
Have you tried the exe that I included in the zip? It gave the same problem on two different computers, with two different wav files. Can I email to you the wav file that I tested with? It is too large to upload to this forum.
wilhelms@intekom.co.za
Active Member

Posts: 7
Joined: May 21st, 2007, 11:54 am

Even your executable file works properly.

Kambiz

Kambiz

Posts: 2430
Joined: March 7th, 2003, 7:10 pm

Thanks Kambiz, I have mailed the WAV to you.
wilhelms@intekom.co.za
Active Member

Posts: 7
Joined: May 21st, 2007, 11:54 am

I got the wave file, and I could see the problem.
Seems the problem is in converting millisecounds to byte offset. I'll let you know when I fixed the bug.
Kambiz

Kambiz

Posts: 2430
Joined: March 7th, 2003, 7:10 pm

I resolved the problem. The bug was inside one of basic functions that was used in several parts of the package.

Thank you
Kambiz

Kambiz

Posts: 2430
Joined: March 7th, 2003, 7:10 pm

### Wave Audio package v1.84

Best regards

Wilhelm
wilhelms@intekom.co.za
Active Member

Posts: 7
Joined: May 21st, 2007, 11:54 am