Page 1 of 1

Start playing a WAV file from a specified position

PostPosted: May 21st, 2007, 12:09 pm
by wilhelms@intekom.co.za
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?

PostPosted: May 21st, 2007, 1:16 pm
by Kambiz
  1. set Paused property to True
  2. call PlayFile method
  3. set Position property
  4. set Paused property to False

PostPosted: May 21st, 2007, 1:45 pm
by wilhelms@intekom.co.za
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.

PostPosted: May 21st, 2007, 1:57 pm
by wilhelms@intekom.co.za
I forgot to mention: The wav is more than 5000 milliseconds long.

Many thanks for your help

Regards

Wilhelm

PostPosted: May 21st, 2007, 2:27 pm
by Kambiz
I was forgotten that recently I changed the behavior, sorry.
Please go in this way:

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


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

Sound interference

PostPosted: May 21st, 2007, 4:41 pm
by wilhelms@intekom.co.za
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

PostPosted: May 21st, 2007, 5:38 pm
by Kambiz
Your sample works as expected with no problem. :!:
What's version of your Wave Audio package?

PostPosted: May 21st, 2007, 6:48 pm
by wilhelms@intekom.co.za
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.

PostPosted: May 21st, 2007, 10:42 pm
by Kambiz
Even your executable file works properly.

Yes, please send me your wave files via email.

PostPosted: May 22nd, 2007, 7:21 am
by wilhelms@intekom.co.za
Thanks Kambiz, I have mailed the WAV to you.

PostPosted: May 22nd, 2007, 10:44 am
by Kambiz
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.

PostPosted: May 22nd, 2007, 11:48 am
by Kambiz
I resolved the problem. The bug was inside one of basic functions that was used in several parts of the package.

Please download the Wave Audio package v1.84.

Thank you

Wave Audio package v1.84

PostPosted: June 6th, 2007, 10:20 am
by wilhelms@intekom.co.za
Many thanks Kambiz. I will download it.

Best regards

Wilhelm