Jump to content

Sound


Guest

Recommended Posts

Message from: "Harry Rogers"

 

Hi Farshad / anyone else.

 

What would be a good way to paly a sound file with Unigui ?

I have a notification window that pops up from time to time and want

the option to have a sound effect with its opening.

 

? Unihtmlframe - but what syntax for maximum browser compatibility.

Any examples greatfully received ....

 

Many thanks

 

Harry Rogers

 

--

 

.

 

Link to comment
Share on other sites

Message from: "Farshad Mohajeri"

 

It seems that using audio tag doesn't work in some cases, but creating audio

element in script seems to work always.

 

Try this:

 

Code for HTML property of TUniHTMLFrame:

 

var audio1 = document.createElement('audio');

audio1.setAttribute('src', 'files/chimes.wav');

audio1.play();

 

Using this method you can also play sound in other events.

 

Put a UniButton on Form and in Click event write:

 

procedure TMainForm.UniButton1Click(Sender: TObject);

begin

WebForm.JSCode('audio1.load();audio1.play();');

end;

 

 

.

 

Link to comment
Share on other sites

Message from: "Harry Rogers"

 

Farshad Mohajeri wrote:

 

> It seems that using audio tag doesn't work in some cases, but

> creating audio element in script seems to work always.

>

> Try this:

>

> Code for HTML property of TUniHTMLFrame:

>

>

> var audio1 = document.createElement('audio');

> audio1.setAttribute('src', 'files/chimes.wav');

> audio1.play();

>

>

> Using this method you can also play sound in other events.

>

> Put a UniButton on Form and in Click event write:

>

> procedure TMainForm.UniButton1Click(Sender: TObject);

> begin

> WebForm.JSCode('audio1.load();audio1.play();');

> end;

 

Thanks for that.

 

--

 

.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...