How to detect when Chrome's “click-to-play” Flash blocking feature is currently active

后端 未结 3 1520
天命终不由人
天命终不由人 2021-02-13 16:09

Tracking state of Chrome\'s Click-to-play feature

How do you detect that a Flash plugin has been temporarily disabled, or, conversely, detect that it has been enabled

相关标签:
3条回答
  • 2021-02-13 16:26

    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");
    }
    
    0 讨论(0)
  • 2021-02-13 16:31

    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.

    0 讨论(0)
  • 2021-02-13 16:36

    For the benefit of others who are looking for the rules around Flash blocking stuff,please see them below:

    • The Flash Content and the page are loaded from the same domain.
      Unknown Width and Height of the Flash Object ie when Chrome gets the width and height as 0 or less than 0.
    • The Flash Content is whitelisted by the user in Chrome Settings.
    • The Width and Height of the Flash Object are less than or equal to 5 each, considering the content to be Tiny and essential.
    • The Width and Height of the Flash object are equal or greater than 398x298.
    • The Aspect Ratio of the content is 16:9, (with an allowed deviation of 0.01) AND the width*height area is at least 120K.

    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.

    0 讨论(0)
提交回复
热议问题