Flowplayer ReferenceError woes (Flash hates mod_deflate!)
But things usually tend to complicate it self day before site launch... and they sure did. I've spent 5 hours trying to figure out why flowplayer didn't work on first load with empty cache on Firefox 3. I tested flowplayer 3.0.6 and commercial-3.1.0dev.
With Flash Player debug version I would get this error:
ReferenceError: Error #1065: Variable Launcher is not defined.
With plain vanilla Flash Player I would get only blank screen with flash loaded but without controls or anything.
At first, I thought it has to do something with the way I am loading the player (jquery document ready, window.onload, flashembed, in head, in body of xhtml....). I tried every possible combination there is.
I was getting nowhere, and as a last straw I tried loading flowplayer directly into the browser without ANY html. BAM, same error! But, to make things worse loading flowplayer swf from flowplayer.com server http://www.jquerytools.org/swf/flowplayer-3.0.7.swf) DID NOT throw the error.
After careful examination of headers, I discovered that I was accidentally gziping swf files on apache level with mod_deflate.
After I removed gzip everything worked as it should.
This is not the first time I made this discovery, but this time I decided to write a blog post as a reminder to my self. :) I remember having same situation some time ago with Internet Explorer and some random .swf files. Other situation where mod_deflate screwed me in the past was when I was gziping xml which Flash was loading on runtime.
AFAIK, mod_deflate compresses swf files and sends them with chunked transfer encoding to the browser. For some reason, last chunk is not detected but flash content is started up. This also explains why flash works after browser refresh. The content is read from browser cache un-chunked.
The solution is to add .swf to the extensions that are not to be compressed by mod_deflate (in your apache config or .htaccess).