0

Dynamic audio problem

asked 2011-05-18 00:25:18 +0800

ramaa gravatar image ramaa
54

Hi,

Is it not possible to set audio file path and as well as cal play in a single method

<audio id="audio" />
<button label ="SPEAK"  onClick="getAudio()"/>
<zscript>
getAudio()
{
    audio.setSrc("sample.wav");
    audio.play();
}
</zscript>

If i call this i get your browser does not support dynamic audio error ....

plz help

delete flag offensive retag edit

6 Replies

Sort by ยป oldest newest

answered 2011-05-23 04:34:48 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

It looks like browser's timing issue, you can invoke two methods separately by using echoEvent or other ways.

link publish delete flag offensive edit

answered 2012-09-19 12:09:15 +0800

ansancle gravatar image ansancle
327 9

I am pushing this back to the top - I really need to get this working, it's critical.

Here is my zul :

<zk xmlns:h="http://www.w3.org/1999/xhtml" xmlns:zk="http://www.zkoss.org/2005/zk">
<window id="_homeWindow" border="normal" apply="com.dh.ui.ipad.view.DHzHomeView"  height="100%" width="100%">	

	<audio id="_audiosound" src="/scripts/buttonclick.mp3'" height="0px" width="0px" visible="true" />
</window>
</zk>

And the Java file :

public class DHzHomeView extends DHzGenericForwardComposer
{
		private Audio _audiosound;

	@Override
	public void doAfterCompose(Component comp) throws Exception
	{				
		super.doAfterCompose(comp);
		_audiosound.play();
		
	}


And the error is "Your browser does not support dynamic audio"

I tried accessing it in a button click callback in case doAfterCompose was not a good place and I got the same error.

link publish delete flag offensive edit

answered 2012-09-20 08:11:35 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

Please use _audiosound.setAutostart(true); instead or use the alternative component - http://code.google.com/p/zk-soundmanager/

link publish delete flag offensive edit

answered 2012-09-20 11:51:48 +0800

ansancle gravatar image ansancle
327 9

Thanks for the response - ironically I ended up using SoundManager2 on my own - not realizing there was a ZK component I could use!
I will try both of these and post code with any working results for future reference.

link publish delete flag offensive edit

answered 2012-09-20 12:27:24 +0800

ansancle gravatar image ansancle
327 9

The <audio tag is still not worklng.

I tried to use the SoundManager component and ran into the following problem. The first time I click the button it will make the sound correctly. Subsequent button pushes produced no sound. Do you have any idea why it would work the first time and not again?

ZUL
.....

	<button id="_soundManagerTestButton" height="100px" label="Sound Manager Test"/>
	<soundmanager id="_soundManager" src="/scripts/buttonclick.mp3" loop="false"/>

....

JAVA

	public void onClick$_soundManagerTestButton(Event event)
	{
		_soundManager.play();		
	}

link publish delete flag offensive edit

answered 2012-09-21 04:07:48 +0800

Col gravatar image Col
135 1 6

I got sound working as follows. It does however require the quicktime plugin to be installed. This has been tested on FF14+ and IE9 (it may work on other browsers and other versions but these are the only ones I can confirm.

In your zul file

<button id="btnPlayTrumpet" label="Play Trumpet" />
<audio id="playTrumpet" src="audio/trumpet.wav" height="0" />

java

public class PlayTrumpet extends SelectorComposer {
   @Wire
   private Audio playTrumpet;

   @Listen("onClick = #btnPlayTrumpet")
   public void startPlaying(Event event) {
      playTrumpet.play();
   }
}

HTH

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2011-05-18 00:25:18 +0800

Seen: 322 times

Last updated: Sep 21 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More