Conversation
- 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
|
Merge #10 before merging this one |
There was a problem hiding this comment.
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.
|
Thanks for the PRs! ❤️ Just the indentation again, and that |
There was a problem hiding this comment.
We could probably avoid all this interval checking and cancelling by using timeouts instead?
There was a problem hiding this comment.
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 valueif (typeof evt.ref.PercentLoaded !== "undefined" && evt.ref.PercentLoaded()) {//Once value == 100 (fully loaded) we can do whatever we wantif (evt.ref.PercentLoaded() === 100) {//Clear interval$interval.cancel(loadCheckInterval);loadCheckInterval = null;//Execute functionfn({evt: evt});//This interval ensures we don't try to access PercentLoaded too soonvar startCheckInterval = $interval(function () {//Ensure Flash Player's PercentLoaded method is availableif (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.
There was a problem hiding this comment.
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 valueif (typeof evt.ref.PercentLoaded !== "undefined" && evt.ref.PercentLoaded()) {//Once value == 100 (fully loaded) we can do whatever we wantif (evt.ref.PercentLoaded() === 100) {//Clear interval$interval.cancel(loadCheckInterval);loadCheckInterval = null;//Execute functionfn({evt: evt});//This interval ensures we don't try to access PercentLoaded too soonvar startCheckInterval = $interval(function () {//Ensure Flash Player's PercentLoaded method is availableif (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.
There was a problem hiding this comment.
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);
}
PercentLoaded()$intervalinstead of$timeoutto check for initial load to solve this problem