-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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
It looks like browser's timing issue, you can invoke two methods separately by using echoEvent or other ways.
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.
Please use _audiosound.setAutostart(true); instead or use the alternative component - http://code.google.com/p/zk-soundmanager/
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.
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(); }
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
Asked: 2011-05-18 00:25:18 +0800
Seen: 322 times
Last updated: Sep 21 '12