First time here? Check out the FAQ!
Hi all,
I am trying to follow the following documentation page: link
I have at the moment local audio files locates at my folder: /home/remie/Downloads/Audio
Below is my example:
I use the following source tag: src="/home/remie/Downloads/Audio/error_01.wav" and activate the controls with controls="true"
However it displays a set of audio controls but i cannot play my sound file.
Should the sound file exist in the Java Project or can it reside somewhere else?
Hi rmalik,
The src attribute will accept a url relative to the ServletContext. (the root of your webapp) This said, you can still use a file located outside of your ServletContext by using the setContent() method on Audio, and passing the File directly:
myAudio.setContent(new AAudio(new File("D:\\test\\file.mp3")));
(test here on windows, but works the same on linux)
You can do this in a composer, or by returning the AAudio in a getter of your viewModel in MVVM
Hi MDuchemin,
Thanks you for your reply! It was exactly what i was looking for!
However i have still a small question. I noticed that i have to place the audio tag in my zul. I would really like just to create a new Audio object in my VM (Like Audio audio = new Audio()).
When i do this and i debug the line i see that my page is null:
if (_page != null) {
getAttachedUiEngine().addResponse(key, response, priority);
} else if (response.getDepends() != this) {
final UiEngine uieng = getCurrentUiEngine();
if (uieng != null)
uieng.addResponse(key, response);
}
Do you know how i can attach my current page to the Audio component?
@cor3000 i used both ways. They give me problems with multiple browsers. I use Opera and Chrome. I get the following message: The parent and child must be in the same desktop.
if (parentpg != null && childpg != null && parentpg.getDesktop() != childpg.getDesktop())
throw new UiException("The parent and child must be in the same desktop: " + parent);
I assume the term Desktop
isn't clear otherwise the error message already explains what's wrong.
In ZK a Desktop
is the server side representation of a browser tab (or iframe). A Session can contain multiple desktops.
This error message should only occur in case you are trying to share components between Desktops, e.g. by storing them in the session and then trying to re-use them in another Desktop (that's my first guess). If that's true, simply don't do that, create/use components only within one Desktop.
(The browser Opera/Chrome is not involved here, since this happens at server side in java code).
Yes, that is correct cor3000. I used the following in the VM:
@Init
public void initSetup( BindContext ctx, @ContextParam( ContextType.VIEW ) Component view )
{
audioManager.setPage(view.getPage());
}
This made ZK behave unexpectedly on different browsers. With a colleague i changed it to the following:
audioManager.setPage(view.getPage().getFirstRoot().getPage());
This seems to work fine. Thanks again for your explanation.
I can't explain or don't understand what this would change. view.getPage()
and view.getPage().getFirstRoot().getPage()
should resolve to the exact same page object.
Still you cannot have the audioManager be attached to multiple pages. Just create a new one for each time you use it.
Asked: 2020-11-17 23:27:32 +0800
Seen: 18 times
Last updated: Dec 15 '20
[Announcement] ZK 8.5.1 is now available!
Highlight new release changes/new features in demo app
How can I make a button change its image by clicking on the same button?
Problems calling function 'sec:isAnyGranted' with zkspring 3.2 and Spring Security 4
webapp folder of ZK spring boot?
Can I set in runtime a new value to library property: org.zkoss.zk.ui.processMask.enabled:
Package ZK Eclipse Tomcat Project For Deployment
AImage org.zkoss.zk.ui.UiException: java.io.FileNotFoundException