Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 17 total
Thread Trying to play a recording with TAudio
Mon, Sep 14 2015 10:56 PMPermanent Link

David Martin

I would like to play a recording using the TAudio component. The recording is MP3 and stored as a blob in a DBISAM table. Button1 has the following OnClick event:

procedure TForm1.Button1Click(Sender: TObject);
begin
  Audio1.SourceURL:=DataSet1.Columns.Column['Recording'].AsString; { Recording is an MP3 blob field }
end;

Audio1.AutoPlay is True. Shouldn't the audio start playing when Button1 is clicked? This does not happen so I must be doing something wrong. Suggestions on getting this to work would be appreciated. Thanks.

David Martin
Tue, Sep 15 2015 7:10 AMPermanent Link

Walter Matte

Tactical Business Corporation

>> Audio1.SourceURL:=DataSet1.Columns.Column['Recording'].AsString; { Recording is an MP3 blob field }

>>Audio1.AutoPlay is True. Shouldn't the audio start playing when Button1 is clicked? This does not happen so I >>must be doing something wrong. Suggestions on getting this to work would be appreciated. Thanks.

David:

Just asking did you look at the multimedia example provided with EWB?  

And does your database have the two fields?

If you look at the Tracks database you will see that the field Sample is the blob - but there is another field Sample_ContentType which must be present if you are using EWB Server and Database - that hold the ContentType.

So, two fields are needed in the table:

BlobXYZ    (a blob holding the mp3 or graphic ...)

and

BlobXYZ_ContentType    (string long enough to hold the content type)

For mp3 - Content-Type html header would be:       audio/mpeg


The EWB Dataset contains a URL in the Sample field, not the physical blob, and when setting the SourceURL then browser will make a request to the server for the content (your mp3 file).


Walter
Tue, Sep 15 2015 7:41 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

David,

<< Audio1.AutoPlay is True. Shouldn't the audio start playing when Button1 is clicked? This does not happen so I must be doing something wrong. Suggestions on getting this to work would be appreciated. Thanks. >>

Yeah, it works fine here, so there's probably a URL/network/cross-origin request issue.

My suggest would be to run your application from an external browser, hit F12 to bring up the developer tools, click on the Network tab, and then start capturing network activity (some browsers require this last step, while others always capture network activity).  Then, click on your Button1 button and see if there are any network issues.

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Sep 15 2015 1:50 PMPermanent Link

David Martin

Perhaps I am getting closer. I did the F12 thingy and this warning came up when I pressed Button1:

HTTP "Content-Type" of "text/plain" is not supported. Load of media resource http://localhost:8211/datasets?dataset=THE_DBISAM_TABLE&method=load&column=Recording&row= failed.

I did not have a Recording_ContentType field (as in the multimedia example) since it was never used in the example. Nevertheless, I have added a Recording_ContentType field with string value 'audio/mpeg'. But I still get the same message as above. Seems like the problem is Content-Type being 'text/plain' when it should be 'audio/mpeg.' Any recommendations on what to try next? Thanks.

DM
Tue, Sep 15 2015 2:07 PMPermanent Link

Walter Matte

Tactical Business Corporation

David Martin wrote:

Perhaps I am getting closer. I did the F12 thingy and this warning came up when I pressed Button1:

HTTP "Content-Type" of "text/plain" is not supported. Load of media resource http://localhost:8211/datasets?dataset=THE_DBISAM_TABLE&method=load&column=Recording&row= failed.

I did not have a Recording_ContentType field (as in the multimedia example) since it was never used in the example. Nevertheless, I have added a Recording_ContentType field with string value 'audio/mpeg'. But I still get the same message as above. Seems like the problem is Content-Type being 'text/plain' when it should be 'audio/mpeg.' Any recommendations on what to try next? Thanks.

DM



I'm surprised the URL doesn't have row=X  (some value) so that it retrieve the correct record.  Does the database have a primary key?  ... I'm only guessing, here...

Walter
Tue, Sep 15 2015 3:51 PMPermanent Link

David Martin

Walter Matte wrote:

""I'm surprised the URL doesn't have row=X  (some value) so that it retrieve the correct record.  Does the database have a primary key?  ... I'm only guessing, here..."

Walter, yes there is a primary key though I do not use it for anything. I, too, noticed that there was no row value but I am not sure what to make of it.

DM
Tue, Sep 15 2015 4:11 PMPermanent Link

Raul

Team Elevate Team Elevate

On 9/14/2015 10:56 PM, David Martin wrote:
>     Audio1.SourceURL:=DataSet1.Columns.Column['Recording'].AsString; { Recording is an MP3 blob field }

Looks like you're trying to load the actual blob MP3 directly into
TAudio - not sure if this is actually supported like this .

EWB audio example actually returns a URL to the audio in the "Sample"
field (i.e.
"datasets?dataset=Tracks&method=load&column=Sample&row=7;1&AlbumNo=7")
and then when you press Play it loads that (a proper URL) into the
TAudio (i.e.
http://www.elevatesoft.com:8081/multimedia/datasets?dataset=Tracks&method=load&column=Sample&row=7;1&AlbumNo=7).

Raul
Tue, Sep 15 2015 5:14 PMPermanent Link

David Martin

Raul wrote:

<<
Looks like you're trying to load the actual blob MP3 directly into TAudio
>>

Raul, I am doing what was done in the example. Although it uses a function call to accomplish it, the code in the example project is equivalent to:

Audio1.SourceURL:=Tracks.Columns['Sample'].AsString; { "Sample" is a blob field that contains the audio }

DM
Tue, Sep 15 2015 9:29 PMPermanent Link

Raul

Team Elevate Team Elevate

On 9/15/2015 5:14 PM, David Martin wrote:
> Raul, I am doing what was done in the example. Although it uses a function call to accomplish it, the code in the example project is equivalent to:
> Audio1.SourceURL:=Tracks.Columns['Sample'].AsString; { "Sample" is a blob field that contains the audio }

IMHO it's not the same thing - your code is assigning a binary value to
 the TAudio controls URL variable (note that ALL of this takes place
client-side  - in the clients browser).

EWB sample is assigning a valid URL that results in a web request to be
sent to the back-end server to retrieve the audio and all the response
headers etc are getting populated (as seen by using browser debug tools).

Anyways, EWB server allows cross origin access so try this :

Replace your button press with this (all on on line).

procedure TForm1.ButtonClick(Sender: TObject);
begin
   Audio1.SourceURL :=
'http://www.elevatesoft.com:8081/multimedia/datasets?dataset=Tracks&method=load&column=Sample&row=7;1&AlbumNo=7';
end;

In my case as soon as click button audio start playing (i set the
AutoPlay true for the TAudio component).

Raul
Tue, Sep 15 2015 9:54 PMPermanent Link

David Martin

Raul wrote:

<<IMHO it's not the same thing>>

Maybe I am wrong, but I think it is the same thing. Maybe Tim can settle this.

DM
Page 1 of 2Next Page »
Jump to Page:  1 2
Image