Usage of Audio component

asked 2020-11-17 23:27:32 +0800

rmalik gravatar image rmalik
31 1

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?

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted

answered 2020-11-18 11:10:14 +0800

MDuchemin gravatar image MDuchemin
1776 1 5
ZK Team

updated 2020-11-18 11:11:04 +0800

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

link publish delete flag offensive edit

answered 2020-11-18 19:02:30 +0800

rmalik gravatar image rmalik
31 1

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?

link publish delete flag offensive edit


I was to quick to ask. You can set it with audio.setPage(Executions.getCurrent().getDesktop().getPage("indexPage")); Thanks again MDuchemin.

rmalik ( 2020-11-18 20:55:45 +0800 )edit

yes you have to add a component to a page either as a root component via setPage() or as a child below another component via setParent(). This is the equivalent of adding the component in a zul page. the result will be the same.

cor3000 ( 2020-11-19 10:53:49 +0800 )edit
Your answer
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




Asked: 2020-11-17 23:27:32 +0800

Seen: 9 times

Last updated: Nov 18

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