videojs/video-js-swf — pull request #106 by heff (2014-07-11 02:17:37+00:00)
Title: Moved 'loadstarted' setting to fix networkState

Fixes #1300 and #1341 -- controls don't show when auto playing with Flash

In a previous change we moved the `loadstart` event to be fired early to match html5 more closely (it's fired as soon as there is a source basically, even if preload=none). This made it so the event might fire before the object is registered with the player, making it so loadstart is never fired, vjs-has-started is never added as a class, and controls don't show.

This is similar to html5 element in that we might miss the loadstart event, and we address that by checking the networkState value. If it's not zero, loadstart was already fired.

The Flash swf has a networkState value, but was returning zero even after loadstart was fired, so that's what this fixes. It moves the loadstarted=true to right before the loadstart event is fired, so that networkState returns greater than zero after that.

@seniorflexdeveloper, @dmlap, @gkatsev -- I'd appreciate a second set of eyes on this (rather urgent) patch. There's other places where loadstarted is checked, and I want to make sure I'm not introducing new errors by moving it to earlier. For instance, it looks like there's a few places where loadstarted is checked to determine if a netstream function should be called, and after this fix we're setting loadstarted to true before netstream is initialized. I can't tell if that's going to be a problem.