How do you detect that a Flash plugin has been temporarily disabled, or, conversely, detect that it has been enabled
To circumvent the Chrome click-to-play throttling, load your SWF from the same domain and protocol as your site.
You can use the AS3 ThrottleEvent
to detect when the SWF has been throttled.
// AS3 code
import flash.events.ThrottleEvent;
import flash.external.ExternalInterface;
stage.addEventListener(ThrottleEvent.THROTTLE, onThrottleEvent);
private function onThrottleEvent(e:ThrottleEvent) {
ExternalInterface.call("onThrottleEvent", e.state); // call javascript function
}
You can setup an ExternalInterface
call to keep track of this state in JavaScript, in JavaScript manage z-index
of your SWF based on if it's throttled or not.
// JS Code
var IS_THROTTLED = false;
window.onThrottleEvent = function (throttleState) {
IS_THROTTLED = (throttleState === "throttle");
}
Add an empty Flash file larger than 398x298 at the bottom of your page. I found once you have at least one Flash file above their minimum Chrome will not pause any of your Flash. You cannot hide this extra Flash file with CSS. Optionally use a javascript timeout (3 seconds) to hide the empty Flash file in case it messes with your page layout. I'm using swfObject for embedding.
For the benefit of others who are looking for the rules around Flash blocking stuff,please see them below:
At least one of the above criterias need to be met, in order to get the content marked as Essential and not get Auto-Paused. Although, I have seen few deviations and Chrome hasn't made any public announcement on the rules yet.