Flash Movie embed code (RubyOnRails)
Last week I was working on a code to make my video files embedding (flv) available for external webpages. There are many ways to implement this and I have documented a simple way to achieve it.
I am using a Video model with file_column plugin to store the flv file. The path of stored flv files is /public/video/file_path/[id]/[filename.flv] in my application. I am using ffmpeg to convert files to flv format but I am not including this module here.
Here is the controller to access the video files from server filesystem.
To make this url http://server.com/video/index/[id] to something DRY like http://server.com/v/[id], add this mapping to your routes.rb file.
map.connect ‘v/:id’, :controller => ‘video’, :action => ’show’
The Video model with embed_code method looks as follows:
Finally, @video.embed_code gives the code to embed a video as a swf object in external html page.


