Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Is it possible to use TAudio with only a WAV file without using a Dataset ?
Wed, Nov 28 2018 6:50 PMPermanent Link

Jose Verger

Cybernav

Avatar

Hello, I have a WAV file that has to be played as alarm when some conditions are met.

Is it possible to load such WAV file with the SourceURL property and play it ?   Because when I try, it executes the Error event and does not play.

regards
Wed, Nov 28 2018 10:39 PMPermanent Link

Raul

Team Elevate Team Elevate

<<
Cybernav wrote:

Hello, I have a WAV file that has to be played as alarm when some conditions are met.

Is it possible to load such WAV file with the SourceURL property and play it ?   Because when I try, it executes the Error event and does not play.
>>

Yes.

What does the error event actually say ?

Raul
Thu, Nov 29 2018 1:59 AMPermanent Link

Michael Dreher

Raul wrote:

 //  What does the error event actually say ?

The TAudio.OnError event is of type TNotifyEvent and doen't give a hint.

May be the browser environment does not support WAV (can be compressed
too). IE for example does not support it, you will not hear it in the IDE.

MIME type support can be tested with code like this:

var
 Audio1 : TAudio;
 CAN_PLAY_MEDIA : array of string = ['cpmCannot', 'cpmMaybe', 'cpmProbably'];

procedure TForm1.Button1Click(Sender: TObject);
begin
  MultiLineEdit1.Lines.Add(CAN_PLAY_MEDIA[Audio1.CanPlayMedia('audio/mpeg')]);
  MultiLineEdit1.Lines.Add(CAN_PLAY_MEDIA[Audio1.CanPlayMedia('audio/ogg')]);
  MultiLineEdit1.Lines.Add(CAN_PLAY_MEDIA[Audio1.CanPlayMedia('audio/wav')]);
end;

My choice is MP3 format when possible. A compatibility list can be found for example here:

https://www.w3schools.com/html/html5_audio.asp

Michael Dreher
Thu, Nov 29 2018 3:44 AMPermanent Link

Matthew Jones

Michael Dreher wrote:

> MIME type support can be tested with code like this:

ALso note that the server may need to be updated to support some file types with the proper MIME type. We had this yesterday with a font.

The Browser console may have a note telling you what the problem is too.

--

Matthew Jones
Thu, Nov 29 2018 10:30 AMPermanent Link

Jose Verger

Cybernav

Avatar

Michael Dreher wrote:

Raul wrote:

 //  What does the error event actually say ?

The TAudio.OnError event is of type TNotifyEvent and doen't give a hint.

May be the browser environment does not support WAV (can be compressed
too). IE for example does not support it, you will not hear it in the IDE.

MIME type support can be tested with code like this:

var
 Audio1 : TAudio;
 CAN_PLAY_MEDIA : array of string = ['cpmCannot', 'cpmMaybe', 'cpmProbably'];

procedure TForm1.Button1Click(Sender: TObject);
begin
  MultiLineEdit1.Lines.Add(CAN_PLAY_MEDIA[Audio1.CanPlayMedia('audio/mpeg')]);
  MultiLineEdit1.Lines.Add(CAN_PLAY_MEDIA[Audio1.CanPlayMedia('audio/ogg')]);
  MultiLineEdit1.Lines.Add(CAN_PLAY_MEDIA[Audio1.CanPlayMedia('audio/wav')]);
end;

My choice is MP3 format when possible. A compatibility list can be found for example here:

https://www.w3schools.com/html/html5_audio.asp

Michael Dreher


Hello,
You are correct, using MP3 instead of WAV solves the issue.  Thanks very much
Image