thuansaritasa / swfobject

Automatically exported from code.google.com/p/swfobject
0 stars 0 forks source link

If swf can't be found using embedSWF, allow to show an error, show alt content #344

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Change the first parm in embedSWF to a swf that failed loading (e.g.
blah.swf")
2. Typically this would not be done, but when hosting swf files on
different server and this parm is dynamically driven from another process,
sometimes path may not exist so want to show an error

What is the expected output? What do you see instead?
Since swf failed loading would expect to see alternate content. Also when
callback is setup in embedSWF, e.success should return false. Currently
e.success returns true even with path to invalid swf. Only way I could get
to return false is to put empty string for path.

What version of the product are you using? On what operating system?
swfobject 2.2, Windows XP SP3, IE 7 

Please provide any additional information below.

Original issue reported on code.google.com by bonassof...@gmail.com on 15 Jul 2009 at 2:57

GoogleCodeExporter commented 9 years ago
Thanks for the feedback, we will take the optimizations into account for the 
next dev
cycle.

Original comment by bobbyvandersluis on 16 Jul 2009 at 12:12

GoogleCodeExporter commented 9 years ago
Just to let you know that this is important for me too.

I help maintain a site from within a Third Level Educational Institution where 
staff
and students access the web from behind a proxy. Access to any site other than 
our
own (which is publicly accessible/not an intranet) requires authentication.

When I view a YouTube video, in a page from our site, that was embedded the 
using the
Dynamic Publishing method, I am asked for authentication. If authenticated the 
video
shows. If not I get nothing, which is unexpected.

Original comment by davesmit...@gmail.com on 8 Oct 2009 at 9:08

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Having same problem. 

I had hoped that the callback facility would let us replace our existing scheme 
that
starts a timer and if it doesn't get an external call from the loaded swf in 10 
secs,
fires an error routine.

Original comment by grey.fre...@gmail.com on 30 Oct 2009 at 8:25

GoogleCodeExporter commented 9 years ago
You can already check for the existence of a loaded SWF by probing the SWF's 
PercentLoaded variable. Anything above 0 indicates that the file was found and 
has started loading.

Here's some sample code:

    var altcontent;

    var callback = function (e){

       if(e.success && e.ref){

          setTimeout(function (){

             if(typeof e.ref.PercentLoaded !== "undefined" && e.ref.PercentLoaded()){ 
                alert("SWF loaded: (el.PercentLoaded(): " +e.ref.PercentLoaded() +").");
                altcontent = null;
             } else {
                alert("SWF failed to load. Restoring ALT content.");
                var div = document.createElement("div");
                div.innerHTML = altcontent;
                e.ref.parentNode.replaceChild(div, e.ref);
             }

          }, 100);

       }

    };

    swfobject.addDomLoadEvent(function (){
       altcontent = document.getElementById("myContent").innerHTML;
    });

    swfobject.embedSWF("test2.swf", "myContent", "300", "120", "8.0.0", "expressInstall.swf", false, false, false, callback);

I successfully tested this example in IE7, IE9, Firefox, Chrome, Safari and 
Opera. The timeout duration might take some playing with, but the gist is there.

If any kind of check were added to SWFObject, it would probably mirror this 
example (or something very similar); there's no way to get around using a timer 
since Flash Player doesn't provide a synchronous "is file path valid" type of 
variable, which forces us to poll the SWF itself.  Flash Player takes a few 
milliseconds to instantiate after the <object> is created in the DOM, so we 
have to set a timer to check the SWF after a small amount of time has passed.

Since this functionality is already available without modifying the library, 
this feature will not be added to SWFObject.

Original comment by platelu...@gmail.com on 31 May 2011 at 10:12