swfobject detect swfurl status 404

I have below code,

var flashvars = {};
flashvars.src = "path-to-src";
flashvars.controlBarAutoHide = "false";
flashvars.poster = "path-to-thumbnail";
flashvars.autoPlay = "false";

var attributes = {};

var params = {};
params.wmode = "transparent";
params.allowfullscreen = "true";

var callbackfn = function(e){
//    console.log(e)
}

swfobject.embedSWF("http://fpdownload.adobe.com/strobe/FlashMediaPlayback.swf", "altContent", "800", "500", "10.2.0", "/path-to/expressInstall.swf", flashvars, params, attributes, callbackfn); 

swfurl i.e.(http://fpdownload.adobe.com/strobe/FlashMediaPlayback.swf) in above code giving me 404 error hence video is not playing

Qn:

  1. Is there a way if swfurl is 404 then we can replace it with other url (path-to-self-domain-swf)

  2. I tried with checking broken URL as well but due to cross domain policy it's not giving me desired result for swfurl status

Answers


SWFObject does not have any feature or ability for checking 404 status. In fact, it will report the embed successful, so long as the markup for the SWF was successfully added to the page. It does not validate that the SWF actually loads and plays.

SWFObject aside, cross-domain client-side 404 detection is not really possible. The most common suggestion is to use AJAX to try to load the file, but this fails when going cross-domain. If you check for errors when loading the file, you will not see specifics about the error (404 vs 403 or 500, etc). This approach is also expensive in terms of page load time and network requests -- you'd be trying to load the file twice.

What I'd do -- and this is a hack -- is try to load your SWF as usual but attach a timer that polls Flash Player to ensure the file is actually loading. If you don't see any progress on the load percentage over a given span of time, you can assume the SWF is not available and the load has failed.

For example (order of operations):

  • Load SWF
  • Wait one or two seconds
  • Poll SWF to check PercentLoaded value
    • If value is above 0, assume SWF is available.
    • If value is still set to "0", wait a little longer to see if it's just a network blip.
      • Poll SWF to check PercentLoaded value
        • If value is above 0, assume SWF is available.
        • If value is still set to "0", assume SWF is unavailable (we will not know why). Use your fallback.

A example for polling the PercentLoaded value of the SWF using SWFObject is available here: http://learnswfobject.com/advanced-topics/executing-javascript-when-the-swf-has-finished-loading/index.html


Need Your Help

Laravel unable to retrieve angular POST data

angularjs laravel post laravel-5 http-post

I am submitting my form data through angular controller. The data then needs to be passed to Laravel Controller and stored in database. But, Laravel does not get the data and the values are NULL

Ruby on Rails - Is there a way to generate a scaffold script from database tables?

ruby-on-rails rubymine

I already have the database tables and I need to create the rails script