Hi Alex,
-------- Original --------
From: Alexander Steitz
Date: 10.03.2010 16:43
> [...]
> If you modeled the class like "qx.ui.embed.Html" then the "a" element can
> only
> end up in the DOM by adding it :)
> I mean: there is no magic code to insert an "a" element in the framework. It
> would be interesting how your class look like.
That is exactly the point that puzzles me currently. Please find my class
appended.
Where those "a"s come from is a mystery still to solve ;)
BTW: The singleton instance is instantiated (and used) like this:
<code>
infodesk.ui.sound.Sound.getInstance().play("infodesk/sound/mail_new.mp3");
</code>
I think those "a"s have something to do with my inheritance/layout/container
setup I've chosen. I'm quite sure that the way I did it is not the best way to
do it :-/
The class attribute (in the HTML-output) is _very_ strange too:
<a href="..." class="rcthfadaoycoyhcccojr"/>
but maybe it's just another of those FireFox-plugins I can't remember anymore
;)
> [...]
> I meant you can extend "qx.ui.embed.Html" and customize the "_applyHtml"
> method and the constructor. Extending "qx.ui.core.Widget" and adding your
> functionality like "qx.ui.embed.Html" class is also a possibility.
That's (first option) what I did (see attachment)
> cheers,
> Alex
Cheers,
Peter
/* ************************************************************************
InfoDesk - The qooxdoo based PSV3 information web-application
http://www.psv3.de
http://qooxdoo.org
Copyright:
2008-2010 Technische Informations-Systeme GmbH, http://www.tis-gmbh.de
Authors:
* Peter Schneider (ps)
************************************************************************ */
/**
* Wrapper class to play audio directly from the browser.
*/
qx.Class.define("infodesk.ui.sound.Sound",
{
extend : qx.ui.embed.Html,
type : "singleton",
/*
*****************************************************************************
CONSTRUCTOR
*****************************************************************************
*/
/**
* Creates one instance of a sound object
*/
construct : function ()
{
this.base(arguments);
this.__initTemplate();
var widget = new qx.ui.container.Composite;
widget.setLayout(new qx.ui.layout.Basic);
widget.add(this);
// Automatically add to application's root
qx.core.Init.getApplication().getRoot().add(widget);
},
/*
*****************************************************************************
PROPERTIES
*****************************************************************************
*/
properties :
{
/** URL of the sound to be played */
url : {
check : "String",
nullable : true,
apply : "__applyUrl"
}
},
/*
*****************************************************************************
MEMBERS
*****************************************************************************
*/
members :
{
/**
* {qx.util.Template} HTML-Element (template) to be inserted into the DOM
*/
__template : null,
/**
* Play sound.
* If <code>vUrl</code> is omitted, this will play the last sound again.
*
* @type member
* @param vUrl {String|null} optional sound URL to play
* @return {void}
*/
play : function (vUrl)
{
if (infodesk.util.Validation.isInvalid(vUrl)) {
vUrl = this.getUrl();
}
this.setUrl(null);
this.setUrl(vUrl);
},
/*
---------------------------------------------------------------------------
APPLY ROUTINES
---------------------------------------------------------------------------
*/
// property apply (overridden)
_applyHtml : function (value, old)
{
var elem = this.getContentElement();
// Insert HTML content
elem.setAttribute("html", value||"");
},
// property apply
__applyUrl : function (value, old)
{
this.setHtml(null); // force re-creation
if (value !== null)
{
var uri = qx.util.ResourceManager.getInstance().toUri(value);
this.setHtml( this.__template.run({ url: uri }) );
}
},
/*
---------------------------------------------------------------------------
INTERNAL INITIALIZE HELPER
---------------------------------------------------------------------------
*/
/**
* Initializes the template member with the HTML-Element (template) that
* fits to the browser/feature/plugin setup of the client.
*
* @type member
* @return {void}
*/
__initTemplate : function ()
{
this.__template = new qx.util.Template(
'<embed src="{url}" style="height: 0px" loop="false" autostart="true"
hidden="true"/>'
);
/* UNTESTED THOUGHTS:
if (qx.bom.client.Multimedia.has("quicktime")) {
template.setContent('<embed src="{uri} width="0" height="0"
type="audio/mpeg" autostart="true" hidden="true" loop="false"/>');
}
else if (qx.bom.client.Multimedia.has("wmv")) {
template.setContent('<object data="{uri} type="application/x-mplayer2"
hidden="true"></object>');
}
else if (navigator.plugins && typeof navigator.plugins["RealPlayer"] ===
"object") {
template.setContent('<embed src="{uri}"
type="audio/x-pn-realaudio-plugin" style="height:0" loop="false"
autostart="true" hidden="true"/>');
}
*/
}
}
});
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel