Zend Framework & Flash

Here’s a quick little “gotcha” when using the Zend PHP Framework:

If you plan on using Flash at all (i.e., SWF or FLV files) be sure to append the necessary extensions the .htaccess file in the “public” folder to the rewrite rule:

RewriteEngine On
RewriteRule !\.(js|ico|gif|jpg|png|css|swf|flv)$ index.php

Note the added “swf” and “flv” extensions. Otherwise access to these files will return an error. Firebug (if you use it) will say that the files are being loaded (200 OK), but if you look at the response, it’s the error page not the actually requested file that is being returned.

Granted, this isn’t exclusive to the Zend Framework – it’s a result of the .htaccess configuration (regardless of which framework/engine you use); but it’s just something to keep in mind.

Update:

Here’s a better declaration (via: http://framework.zend.com/manual/en/zend.application.quick-start.html):

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

10 thoughts on “Zend Framework & Flash”

  1. eingko, thanks for that bit of advice. I have one related problem that you may know that answer to. I can get the flash video to play fine but it is missing the skin for the video player. Any thoughts? Thanks.

  2. Scott, your video player .swf file is probably looking for the skin .swf file on the root level. You can either drop the skin file on the root (easy) or you can change the directory within which the player searches for the skin .swf file by setting the FLVPlayback.skin value to the directory where you skin is stored.

    For example if your skin file is “ClearOverPlaySeekMute.swf” and it’s in the “flash” directory on the root level and your FLVPlayback component is called “myPlayer” you would add a frame script with the following:

    myPlayer.skin = "/flash/ClearOverPlaySeekMute.swf";

    Hope that answers your question.

  3. eingko, I’m sure you are on the right track, but I’m still having a few troubles.

    When you refer to myPlayer.skin, is myPlayer the name of the .fla file that the swf is published from?

    Also, will each Zend Framework view script be able to find the skin if the path specified in the Action Script is relative? Should I do something like myPlayer.skin = “http://www.example.com/flash/ClearOverPlaySeekMute.swf”;

    I would like to be able to put the the flash video in the public_html/flash/ directory once and have any of the following controllers be able to render a view of it. (ie. http://www.example.com/index/; http://www.example.com/home/; http://www.example.com/home/about/).

    Thanks again for your help.

  4. No, “myPlayer” is the name you will assign to the FLVPlayback component on the stage. “myPlayer.skin = ‘/flash/ClearOverPlaySeekMute.swf’” is the path to the skin file that you assign on a frame (likely, the first) in your .fla file. The .swf will be named whatever your .fla file is named (by default). Make sure that you upload BOTH the player.swf and the skin.swf file to the “public_html/flash” directory.

    I would recommend using a relative URL (i.e., “/flash/”), but you can make it absolute if you wish. It should be accessible from any view, as long as you make sure that your URL is correct.

  5. You are a life saver man. If ever in nairobi (Capital of kenya) get in touch and ill buy you a beer!!

Comments are closed.