Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

modifying xul dynamically with javascript

3 views
Skip to first unread message

bspencer

unread,
Mar 1, 2007, 4:15:13 AM3/1/07
to
I have a very simple xulrunner app that plays a flash file. It works
with a file name hard coded. I want to pass the flash file in as a
parameter. I have javascript code that sets the src variable and
checks it, but it doesn't seem to make a difference. This works in
normal HTML, just not in my XUL code.

<javascript snippet>
...
var flashObj = document.getElementById("theXULFlashObject");
alert (flashObj); //not null
alert (flashObj.getAttribute("src")); //shows correct value
flashObj.setAttribute("src", "newFlashFile.swf");
alert (flashObj.getAttribute("src")); //shows correct new value
...

but the original flash file still plays.

Many thanks for some pointers.
Bob

migm...@gmail.com

unread,
Mar 1, 2007, 2:54:51 PM3/1/07
to
On Mar 1, 1:15 am, "bspencer" <spencer...@gmail.com> wrote:
> This works in
> normal HTML, just not in my XUL code.
>
> <javascript snippet>
> ...
>

Ah, we had something of the same problem in Songbird when we first
started working with media plugins and migrating from HTML to XUL.

>From what I was told, plugins initialize differently with an
<html:object> in a XUL file than from <object> in an HTML file. You
apparently can't actually get them with their real JS API available
until the onload event or later.

Also I've found in some cases setting an attribute directly on a
plugin locks it to that value, while leaving it blank in the xml and
setting it in js allows it to change freely. That's probably
something dumb on the plugin implementer's part.

Lastly, there might likely be a better native API on the flash plugin
to tell it to load a different asset, I don't know flash that well.

We only used a single .swf file when we were testing with a
crossplatform flash-based core, but it was written to extend itself
into javascript and accept different MP3 urls for full playback
control -- at worst you could probably do something similar. Or maybe
use an <iframe> instead of an <html:object> and switch urls on that?

Good luck!

mig

Anatolij Kupriyanov

unread,
Mar 3, 2007, 7:02:38 PM3/3/07
to
bspencer wrote:

> flashObj.setAttribute("src", "newFlashFile.swf");

> but the original flash file still plays.

Maybe you can try create a new element. So, instead of changing old html:object you can create a new object with other
@src and replace the old one with the new one.

Philip Chee

unread,
Mar 5, 2007, 6:01:51 AM3/5/07
to

In our flashblock.xbl we do this:

current.StopPlay();
current.LoadMovie(0, "");

Phil

--
Philip Chee <phi...@aleytys.pc.my>, <phili...@gmail.com>
http://flashblock.mozdev.org/ http://xsidebar.mozdev.org
Guard us from the she-wolf and the wolf, and guard us from the thief,
oh Night, and so be good for us to pass.
[ ]Make sure to include BUGS=OFF in your config.sys!
* TagZilla 0.059.4

0 new messages