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

后端 未结 3 1525
天命终不由人
天命终不由人 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");
    }
    

提交回复
热议问题