View Full Version : Programatically set url of Ext.Audio

21 Oct 2010, 2:23 AM
is there a way to programatically set url of Ext.Audio. I checked the docs and could find any function like setUrl.

21 Oct 2010, 2:59 AM
This is kinda a hack I gues but it works.
I select the audio tag and change the src attribute of it. And this function does the trick


Where audio the audio tag.

Is there a sencha way of doing this?

21 Oct 2010, 4:30 PM
Don't know if this is what you want, but I set the url like this:

this.hiddenAudio.url = yourURL;

where hiddenAudio is:

this.hiddenAudio = new Ext.Audio({
enableControls: false,
url: 'crash.mp3', //initial audio url
loop: false,
listeners: {
scope: this

This way I play audio selected from a list component.

Does that help?


21 Oct 2010, 10:18 PM
so when u change the url and press play does the new audio file play. I tried this method earlier and it didnt switch dynamically. So i had to use. audiotag.load();

22 Oct 2010, 8:43 AM
Blessan, you're right. I had a look at what exactly I did to get it to work. I have a very lame implementation to get around that problem. I work with extended panel classes and found that if I called this.initComponent(); right before I change the url as mentioned above, it worked.

I have a comment in my code to urgently find a better solution:( So it works for me, but only with some very lame workaround which I cannot explain.

It seems the Ext.Audio code is still very shaky. I find it very hard to work with and there seems to still be a lot of problems (see my other threads about broken audio in 0.97).

I'd be happy to send you code for what I did.


22 Oct 2010, 7:50 PM
it would be good to see ur code. I used Ext.audio. I didnt extend anythin. And used css selectors to get the audio tag.

1 Mar 2011, 12:52 PM
This is how I did it:-

Set up a hidden audio .....

var audioBase = {
url: 'aSoundFile.mp3',
loop: true

var player = new Ext.Audio(Ext.apply({}, audioBase, {
title: 'Hidden',
enableControls: true,
layout: {
type: 'vbox',
pack: 'center'

It needs a layout too even though it is hidden.

Other buttons and stuff

Then to change url and apply the change:-

player.media.dom.src = newURL;