callback da flashembed di strumenti jQuery
-
26-10-2019 - |
Domanda
jQuery Tools include un'API flashembed che accetta molti parametri. C'è uno che accetta funzione di callback e incendi dopo lo stato successo della manifestazione Flash Player carico?
playerdiv.flashembed(url+'/VIPlayer.swf','knds_player',300,250,'8.0.0',false,flashVars);
Informazioni:. sito ufficiale
Nota: Questo è possibile in Google SWFObject biblioteca come di seguito:
swfobject.embedSWF(url+'/VIPlayer.swf','knds_player',300,250,'8.0.0',false,flashVars,callBack);
function callBack(event){
event after successful display of code
}
Ma ho bisogno di usare flashembed solo. Puoi Please help me qui?
Grazie in anticipo :)
Soluzione
Il metodo flashembed ha un argomento onFail
che prende un callback come valore:
$("#flash").flashembed({
src: flashSWF,
version:[10,0],
id:"flashObj",
width: 500,
height: 300,
wmode: "opaque",
cachebusting: "false",
allowscriptaccess: "always",
api: "false",
scale: "noscale",
menu: "false",
onFail: flasherror("#flash")
})
Si spara inavvertitamente sia successo e fallimento. Cerca per il personaggio ,
di distinguere tra i due stati. In caso di errore, si presenta come delimitatore nella stringa di versione, come ad esempio 11,0
piuttosto che 11.0
:
function flashError(domnode, newtext){
function failState()
{
if ($(domnode).html().search(/,/) !== -1) //player failed to load
{
newtext = $(domnode).html(); // store default error string
$(domnode).empty();
$(domnode).append(newtext.replace(/,/g,".")); // replace comma with period
if ($(domnode).hasClass("flashmsg") === false)
{
$(domnode).addClass("flashmsg"); // add class to custom error element
}
}
else
{
//success logic
}
}
// observer constructor
var cursor =
typeof window.hasOwnProperty === "function" ?
window.hasOwnProperty("WebKitMutationObserver")
? new WebKitMutationObserver(startValidation)
: window.hasOwnProperty("MutationObserver")
? new MutationObserver(startValidation)
: false
: false
;
//Use observer event if it exists
if (cursor)
{
//Bind observer event to text child of the dom node
cursor.observe($(domnode).get(0), { childList: true } );
return;
}
//Use mutation event as a fallback
else if (!!document.addEventListener)
{
$(domnode).get(0).addEventListener("DOMNodeInserted", failState, false);
}
//Use readystatechange event for legacy IE
else
{
$(domnode).get(0).addBehavior("foo.htc");
$(domnode).get(0).attachEvent("onreadystatechange", failState);
}
Riferimenti