Changing audio source

Hi,

I’m trying to code a music player in Vaadin. I’m using its built in Audio component.

The way I want this to work is that I select a file in a tree and it plays that audio file.

I set the correct source file in my tree handler:

Tree tree = new Tree();
    FilesystemContainer container = new FilesystemContainer(file);
    tree.setContainerDataSource(container);
    tree.setImmediate(true);
    mainWindow.addComponent(tree);

tree.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {

            System.out.println(event);
            File file = (File) event.getProperty().getValue();
            FileResource resource = new FileResource(file, application);
            audio.setSource(resource);
            audio.pause();
            audio.requestRepaint();
        }
    });

However, I must refresh the page manually for this to work. How can I make the audio component pick up the new source without refreshing the page?