Skip to content
This repository was archived by the owner on Sep 15, 2024. It is now read-only.

Comments

=BG= make swfLoadEvent() more robust#8

Open
bguiz wants to merge 1 commit intojeef3:masterfrom
bguiz:patch-1
Open

=BG= make swfLoadEvent() more robust#8
bguiz wants to merge 1 commit intojeef3:masterfrom
bguiz:patch-1

Conversation

@bguiz
Copy link

@bguiz bguiz commented Nov 12, 2015

  • some race conditions observed in chrome's flash pepper player (too fast or too slow to call PercentLoaded()
  • use $interval instead of $timeout to check for initial load to solve this problem

Review on Reviewable

- some race conditions observed in chrome's flash pepper player (too fast or too slow to call `PercentLoaded()`
- use `$interval` instead of `$timeout` to check for initial load to solve this problem
@bguiz
Copy link
Author

bguiz commented Nov 12, 2015

Merge #10 before merging this one

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only bit I'm not really keen on. I like setFocusOnFlash, but I would maybe prefer it as an option passed in to the directive? I don't necessarily want my Flash objects to gain focus when they load.

@jeef3
Copy link
Owner

jeef3 commented Nov 13, 2015

Thanks for the PRs! ❤️

Just the indentation again, and that setFocusOnFlash that I'm not sure about.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably avoid all this interval checking and cancelling by using timeouts instead?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with time outs is that they are only ever going to be called
once. So you have to set generous initial wait times to compensate.

If you are loading many small flash files (my use case is that of unloading
one and loading the next in quick succession) then the lag makes for poor
UX. Better to use small intervals instead.
On 14 Nov 2015 07:23, "Jeff Knaggs" notifications@github.com wrote:

In angular-swfobject.js
#8 (comment):

  •        var loadCheckInterval = $interval(function () {
    
  •          //Ensure Flash Player's PercentLoaded method is available and returns a value
    
  •          if (typeof evt.ref.PercentLoaded !== "undefined" && evt.ref.PercentLoaded()) {
    
  •            //Once value == 100 (fully loaded) we can do whatever we want
    
  •            if (evt.ref.PercentLoaded() === 100) {
    
  •              //Clear interval
    
  •              $interval.cancel(loadCheckInterval);
    
  •              loadCheckInterval = null;
    
  •              //Execute function
    
  •              fn({evt: evt});
    
  •        //This interval ensures we don't try to access PercentLoaded too soon
    
  •        var startCheckInterval = $interval(function () {
    
  •            //Ensure Flash Player's PercentLoaded method is available
    
  •            if (typeof evt.ref.PercentLoaded !== 'undefined') {
    
  •                $interval.cancel(startCheckInterval);
    
  •                startCheckInterval = null;
    

We could probably avoid all this interval checking and cancelling by using
timeouts instead?


Reply to this email directly or view it on GitHub
https://github.com/jeef3/angular-swfobject/pull/8/files#r44829669.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If timeouts are to be used, then I reckon the failure cases must be handled
manually. In this case, when flash hasn't loaded in time.
On 14 Nov 2015 08:48, "Brendan Graetz" brendan.graetz@gmail.com wrote:

The problem with time outs is that they are only ever going to be called
once. So you have to set generous initial wait times to compensate.

If you are loading many small flash files (my use case is that of
unloading one and loading the next in quick succession) then the lag makes
for poor UX. Better to use small intervals instead.
On 14 Nov 2015 07:23, "Jeff Knaggs" notifications@github.com wrote:

In angular-swfobject.js
#8 (comment):

  •        var loadCheckInterval = $interval(function () {
    
  •          //Ensure Flash Player's PercentLoaded method is available and returns a value
    
  •          if (typeof evt.ref.PercentLoaded !== "undefined" && evt.ref.PercentLoaded()) {
    
  •            //Once value == 100 (fully loaded) we can do whatever we want
    
  •            if (evt.ref.PercentLoaded() === 100) {
    
  •              //Clear interval
    
  •              $interval.cancel(loadCheckInterval);
    
  •              loadCheckInterval = null;
    
  •              //Execute function
    
  •              fn({evt: evt});
    
  •        //This interval ensures we don't try to access PercentLoaded too soon
    
  •        var startCheckInterval = $interval(function () {
    
  •            //Ensure Flash Player's PercentLoaded method is available
    
  •            if (typeof evt.ref.PercentLoaded !== 'undefined') {
    
  •                $interval.cancel(startCheckInterval);
    
  •                startCheckInterval = null;
    

We could probably avoid all this interval checking and cancelling by
using timeouts instead?


Reply to this email directly or view it on GitHub
https://github.com/jeef3/angular-swfobject/pull/8/files#r44829669.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like:

function swfLoadEvent(evt, fn) {
  // First check is straight away
  if (!evt.ref.PercentLoaded || evt.rer.PercentLoaded() === 100) {
    onLoaded();
    return;
  }

  // Then check every 10ms?
  $timeout(function () { swfLoadEvent(evt, fn) }, 10);
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants