summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-02-22 05:21:44 +0000
committerBharat Mediratta <bharat@menalto.com>2009-02-22 05:21:44 +0000
commitbaff63b70b2b686b14f468a26180081ad505ce9a (patch)
tree6e2013bfa64dcaae1be5a9c4fa3d4bc1a508fefb
parente6836d8a5ed06cb25c3f0d61b1c24a48e49e93f3 (diff)
Very basic movie support. You can upload a FLV file, we use ffmpeg to
extract a thumbnail out of it and if you click through we show it using flowplayer.
-rw-r--r--core/SimpleUploader.swfbin301344 -> 301344 bytes
-rw-r--r--core/controllers/movies.php103
-rw-r--r--core/controllers/simple_uploader.php16
-rw-r--r--core/helpers/graphics.php47
-rw-r--r--core/helpers/movie.php121
-rw-r--r--core/helpers/photo.php31
-rw-r--r--core/models/item.php21
-rw-r--r--lib/flowplayer.controls.swfbin0 -> 15977 bytes
-rw-r--r--lib/flowplayer.js24
-rw-r--r--lib/flowplayer.swfbin0 -> 92318 bytes
-rw-r--r--themes/default/views/movie.html.php28
11 files changed, 352 insertions, 39 deletions
diff --git a/core/SimpleUploader.swf b/core/SimpleUploader.swf
index b52051a0..2be9841f 100644
--- a/core/SimpleUploader.swf
+++ b/core/SimpleUploader.swf
Binary files differ
diff --git a/core/controllers/movies.php b/core/controllers/movies.php
new file mode 100644
index 00000000..c84ce8d6
--- /dev/null
+++ b/core/controllers/movies.php
@@ -0,0 +1,103 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2008 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class Movies_Controller extends Items_Controller {
+
+ /**
+ * @see REST_Controller::_show($resource)
+ */
+ public function _show($photo) {
+ access::required("view", $photo);
+
+ // We sort by id ascending so for now, find sibling info by doing id based queries.
+ $next_item = ORM::factory("item")
+ ->viewable()
+ ->where("parent_id", $photo->parent_id)
+ ->where("id >", $photo->id)
+ ->orderby("id", "ASC")
+ ->find();
+ $previous_item = ORM::factory("item")
+ ->viewable()
+ ->where("parent_id", $photo->parent_id)
+ ->where("id <", $photo->id)
+ ->orderby("id", "DESC")
+ ->find();
+ $position = ORM::factory("item")
+ ->viewable()
+ ->where("parent_id", $photo->parent_id)
+ ->where("id <=", $photo->id)
+ ->count_all();
+
+ $template = new Theme_View("page.html", "photo");
+ $template->set_global("item", $photo);
+ $template->set_global("children", array());
+ $template->set_global("children_count", $photo->children_count());
+ $template->set_global("parents", $photo->parents());
+ $template->set_global("next_item", $next_item->loaded ? $next_item : null);
+ $template->set_global("previous_item", $previous_item->loaded ? $previous_item : null);
+ $template->set_global("sibling_count", $photo->parent()->children_count());
+ $template->set_global("position", $position);
+
+ $template->content = new View("movie.html");
+
+ $photo->view_count++;
+ $photo->save();
+
+ print $template;
+ }
+
+ /**
+ * @see REST_Controller::_update($resource)
+ */
+ public function _update($photo) {
+ access::required("edit", $photo);
+
+ $form = photo::get_edit_form($photo);
+ if ($form->validate()) {
+ // @todo implement changing the name. This is not trivial, we have
+ // to check for conflicts and rename the album itself, etc. Needs an
+ // api method.
+ $orig = clone $photo;
+ $photo->title = $form->edit_photo->title->value;
+ $photo->description = $form->edit_photo->description->value;
+ $photo->save();
+
+ module::event("item_updated", $orig, $photo);
+
+ log::success("content", "Updated photo", "<a href=\"photos/$photo->id\">view</a>");
+ message::success(t("Saved photo %photo_title", array("photo_title" => $photo->title)));
+
+ print json_encode(
+ array("result" => "success",
+ "location" => url::site("photos/$photo->id")));
+ } else {
+ print json_encode(
+ array("result" => "error",
+ "form" => $form->__toString()));
+ }
+ }
+
+ /**
+ * @see REST_Controller::_form_edit($resource)
+ */
+ public function _form_edit($photo) {
+ access::required("edit", $photo);
+ print photo::get_edit_form($photo);
+ }
+}
diff --git a/core/controllers/simple_uploader.php b/core/controllers/simple_uploader.php
index dca56201..e163a023 100644
--- a/core/controllers/simple_uploader.php
+++ b/core/controllers/simple_uploader.php
@@ -46,16 +46,18 @@ class Simple_Uploader_Controller extends Controller {
access::verify_csrf();
$file_validation = new Validation($_FILES);
- $file_validation->add_rules("file", "upload::valid", "upload::type[gif,jpg,png]");
+ $file_validation->add_rules("file", "upload::valid", "upload::type[gif,jpg,png,flv]");
if ($file_validation->validate()) {
$temp_filename = upload::save("file");
$title = substr(basename($temp_filename), 10); // Skip unique identifier Kohana adds
- $photo = photo::create(
- $album,
- $temp_filename,
- $title,
- $title);
- log::success("content", "Added a photo", html::anchor("photos/$photo->id", "view photo"));
+ $path_info = pathinfo($temp_filename);
+ if ($path_info["extension"] == "flv") {
+ $movie = movie::create($album, $temp_filename, $title, $title);
+ log::success("content", "Added a movie", html::anchor("movies/$movie->id", "view movie"));
+ } else {
+ $photo = photo::create($album, $temp_filename, $title, $title);
+ log::success("content", "Added a photo", html::anchor("photos/$photo->id", "view photo"));
+ }
}
}
diff --git a/core/helpers/graphics.php b/core/helpers/graphics.php
index 4ec21ee8..2ea92873 100644
--- a/core/helpers/graphics.php
+++ b/core/helpers/graphics.php
@@ -115,7 +115,7 @@ class graphics_Core {
->where("target", $target)
->orderby("priority", "asc")
->find_all() as $rule) {
- $args = array($working_file, $output_file, unserialize($rule->args));
+ $args = array($item, $working_file, $output_file, unserialize($rule->args));
call_user_func_array(array("graphics", $rule->operation), $args);
$working_file = $output_file;
}
@@ -141,35 +141,43 @@ class graphics_Core {
* Resize an image. Valid options are width, height and master. Master is one of the Image
* master dimension constants.
*
- * @param string $input_file
- * @param string $output_file
- * @param array $options
+ * @param Item_Model $item
+ * @param string $input_file
+ * @param string $output_file
+ * @param array $options
*/
- static function resize($input_file, $output_file, $options) {
+ static function resize($item, $input_file, $output_file, $options) {
if (!self::$init) {
self::init_toolkit();
}
- Image::factory($input_file)
- ->resize($options["width"], $options["height"], $options["master"])
- ->save($output_file);
+ if ($item->is_movie()) {
+ movie::extract_frame($input_file, $output_file);
+ } else if ($item->is_photo()) {
+ Image::factory($input_file)
+ ->resize($options["width"], $options["height"], $options["master"])
+ ->save($output_file);
+ }
}
/**
* Rotate an image. Valid options are degrees
*
- * @param string $input_file
- * @param string $output_file
- * @param array $options
+ * @param Item_Model $item
+ * @param string $input_file
+ * @param string $output_file
+ * @param array $options
*/
- static function rotate($input_file, $output_file, $options) {
+ static function rotate($item, $input_file, $output_file, $options) {
if (!self::$init) {
self::init_toolkit();
}
- Image::factory($input_file)
- ->rotate($options["degrees"])
- ->save($output_file);
+ if ($item->is_photo()) {
+ Image::factory($input_file)
+ ->rotate($options["degrees"])
+ ->save($output_file);
+ }
}
/**
@@ -177,11 +185,12 @@ class graphics_Core {
* transparency_percent.
* position is one of northwest, north, northeast, west, center, east, southwest, south, southeast
*
- * @param string $input_file
- * @param string $output_file
- * @param array $options
+ * @param Item_Model $item
+ * @param string $input_file
+ * @param string $output_file
+ * @param array $options
*/
- static function composite($input_file, $output_file, $options) {
+ static function composite($item, $input_file, $output_file, $options) {
if (!self::$init) {
self::init_toolkit();
}
diff --git a/core/helpers/movie.php b/core/helpers/movie.php
new file mode 100644
index 00000000..99b9180a
--- /dev/null
+++ b/core/helpers/movie.php
@@ -0,0 +1,121 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2008 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/**
+ * This is the API for handling movies.
+ *
+ * Note: by design, this class does not do any permission checking.
+ */
+class movie_Core {
+ /**
+ * Create a new movie.
+ * @param integer $parent_id id of parent album
+ * @param string $filename path to the photo file on disk
+ * @param string $name the filename to use for this photo in the album
+ * @param integer $title the title of the new photo
+ * @param string $description (optional) the longer description of this photo
+ * @return Item_Model
+ */
+ static function create($parent, $filename, $name, $title,
+ $description=null, $owner_id=null) {
+ if (!$parent->loaded || !$parent->is_album()) {
+ throw new Exception("@todo INVALID_PARENT");
+ }
+
+ if (!is_file($filename)) {
+ throw new Exception("@todo MISSING_MOVIE_FILE");
+ }
+
+ $movie_info = movie::getmoviesize($filename);
+
+ // Force an extension onto the name
+ $pi = pathinfo($name);
+ if (empty($pi["extension"])) {
+ $pi["extension"] = image_type_to_extension($movie_info[2], false);
+ $name .= "." . $pi["extension"];
+ }
+
+ $movie = ORM::factory("item");
+ $movie->type = "movie";
+ $movie->title = $title;
+ $movie->description = $description;
+ $movie->name = $name;
+ $movie->owner_id = $owner_id;
+ $movie->width = $movie_info[0];
+ $movie->height = $movie_info[1];
+ $movie->mime_type = empty($image_info["mime"]) ? "application/unknown" : $image_info["mime"];
+ $movie->thumb_dirty = 1;
+ $movie->resize_dirty = 1;
+
+ // Randomize the name if there's a conflict
+ while (ORM::Factory("item")
+ ->where("parent_id", $parent->id)
+ ->where("name", $movie->name)
+ ->find()->id) {
+ // @todo Improve this. Random numbers are not user friendly
+ $movie->name = rand() . "." . $pi["extension"];
+ }
+
+ // This saves the photo
+ $movie->add_to_parent($parent);
+ copy($filename, $movie->file_path());
+
+ module::event("item_created", $movie);
+
+ // Build our thumbnail
+ graphics::generate($movie);
+
+ // If the parent has no cover item, make this it.
+ $parent = $movie->parent();
+ if ($parent->album_cover_item_id == null) {
+ $parent->album_cover_item_id = $movie->id;
+ $parent->save();
+ graphics::generate($parent);
+ }
+
+ return $movie;
+ }
+
+ static function getmoviesize($filename) {
+ if (!$ffmpeg = exec("which ffmpeg")) {
+ throw new Exception("@todo MISSING_FFMPEG");
+ }
+ $cmd = escapeshellcmd($ffmpeg) . " -i " . escapeshellarg($filename) . " 2>&1";
+ $result = `$cmd`;
+ if (preg_match("/Stream.*?Video:.*?(\d+)x(\d+).*\ +([0-9\.]+) (fps|tb).*/",
+ $result, $regs)) {
+ list ($width, $height) = array($regs[1], $regs[2]);
+ } else {
+ list ($width, $height) = array(0, 0);
+ }
+ return array($width, $height);
+ }
+
+ function extract_frame($input_file, $output_file) {
+ if (!$ffmpeg = exec("which ffmpeg")) {
+ throw new Exception("@todo MISSING_FFMPEG");
+ }
+
+ $cmd = escapeshellcmd($ffmpeg) . " -i " . escapeshellarg($input_file) .
+ " -t 0.001 -y -f mjpeg " . escapeshellarg($output_file);
+ printf("<pre>%s</pre>",print_r($cmd,1));flush();
+ exec($cmd);
+ }
+}
diff --git a/core/helpers/photo.php b/core/helpers/photo.php
index a571943d..9b773dc4 100644
--- a/core/helpers/photo.php
+++ b/core/helpers/photo.php
@@ -43,8 +43,13 @@ class photo_Core {
throw new Exception("@todo MISSING_IMAGE_FILE");
}
- if (!($image_info = getimagesize($filename))) {
- throw new Exception("@todo INVALID_IMAGE_FILE");
+ $image_info = getimagesize($filename);
+ if ($image_info) {
+ $type = "photo";
+ } else {
+ $movie_info = movie::getmoviesize($filename);
+ $image_info = array(200, 200, 'mime' => 'video/x-flv');
+ $type = "movie";
}
// Force an extension onto the name
@@ -55,7 +60,7 @@ class photo_Core {
}
$photo = ORM::factory("item");
- $photo->type = "photo";
+ $photo->type = $type;
$photo->title = $title;
$photo->description = $description;
$photo->name = $name;
@@ -81,15 +86,17 @@ class photo_Core {
module::event("item_created", $photo);
- // Build our thumbnail/resizes
- graphics::generate($photo);
+ if ($type == "photo") {
+ // Build our thumbnail/resizes
+ graphics::generate($photo);
- // If the parent has no cover item, make this it.
- $parent = $photo->parent();
- if ($parent->album_cover_item_id == null) {
- $parent->album_cover_item_id = $photo->id;
- $parent->save();
- graphics::generate($parent);
+ // If the parent has no cover item, make this it.
+ $parent = $photo->parent();
+ if ($parent->album_cover_item_id == null) {
+ $parent->album_cover_item_id = $photo->id;
+ $parent->save();
+ graphics::generate($parent);
+ }
}
return $photo;
@@ -102,7 +109,7 @@ class photo_Core {
$group->input("name")->label(t("Name"));
$group->input("title")->label(t("Title"));
$group->textarea("description")->label(t("Description"));
- $group->upload("file")->label(t("File"))->rules("required|allow[jpg,png,gif]");
+ $group->upload("file")->label(t("File"))->rules("required|allow[jpg,png,gif,flv]");
$group->hidden("type")->value("photo");
$group->submit("")->value(t("Upload"));
$form->add_rules_from(ORM::factory("item"));
diff --git a/core/models/item.php b/core/models/item.php
index e29f3245..da0e7eb3 100644
--- a/core/models/item.php
+++ b/core/models/item.php
@@ -84,6 +84,14 @@ class Item_Model extends ORM_MPTT {
return $this->type == 'photo';
}
+ /**
+ * Is this item a movie?
+ * @return true if it's a movie
+ */
+ public function is_movie() {
+ return $this->type == 'movie';
+ }
+
public function delete() {
$original_path = $this->file_path();
$original_resize_path = $this->resize_path();
@@ -308,7 +316,7 @@ class Item_Model extends ORM_MPTT {
}
/**
- * Return an <img> tag for the thumbnail.
+ * Return an <img> tag for the resize.
* @param array $extra_attrs Extra attributes to add to the img tag
* @return string
*/
@@ -319,4 +327,15 @@ class Item_Model extends ORM_MPTT {
"height" => $this->resize_height),
$extra_attrs);
}
+
+ public function movie_tag($extra_attrs) {
+ return html::anchor($this->file_url(true), "",
+ array_merge(
+ $extra_attrs,
+ array("id" => "player",
+ "style" => "display:block;width:400px;height:300px"))) .
+ "<script>flowplayer('player', '" .
+ url::abs_file("lib/flowplayer-3.0.5.swf") .
+ "'); </script>";
+ }
}
diff --git a/lib/flowplayer.controls.swf b/lib/flowplayer.controls.swf
new file mode 100644
index 00000000..09a27e8a
--- /dev/null
+++ b/lib/flowplayer.controls.swf
Binary files differ
diff --git a/lib/flowplayer.js b/lib/flowplayer.js
new file mode 100644
index 00000000..b1c33150
--- /dev/null
+++ b/lib/flowplayer.js
@@ -0,0 +1,24 @@
+/**
+ * flowplayer.js 3.0.5. The Flowplayer API
+ *
+ * Copyright 2009 Flowplayer Oy
+ *
+ * This file is part of Flowplayer.
+ *
+ * Flowplayer is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Flowplayer is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Version: 3.0.5 - Tue Feb 03 2009 13:14:17 GMT-0000 (GMT+00:00)
+ */
+(function(){function log(args){console.log("$f.fireEvent",[].slice.call(args));}function clone(obj){if(!obj||typeof obj!='object'){return obj;}var temp=new obj.constructor();for(var key in obj){if(obj.hasOwnProperty(key)){temp[key]=clone(obj[key]);}}return temp;}function each(obj,fn){if(!obj){return;}var name,i=0,length=obj.length;if(length===undefined){for(name in obj){if(fn.call(obj[name],name,obj[name])===false){break;}}}else{for(var value=obj[0];i<length&&fn.call(value,i,value)!==false;value=obj[++i]){}}return obj;}function el(id){return document.getElementById(id);}function extend(to,from,skipFuncs){if(to&&from){each(from,function(name,value){if(!skipFuncs||typeof value!='function'){to[name]=value;}});}}function select(query){var index=query.indexOf(".");if(index!=-1){var tag=query.substring(0,index)||"*";var klass=query.substring(index+1,query.length);var els=[];each(document.getElementsByTagName(tag),function(){if(this.className&&this.className.indexOf(klass)!=-1){els.push(this);}});return els;}}function stopEvent(e){e=e||window.event;if(e.preventDefault){e.stopPropagation();e.preventDefault();}else{e.returnValue=false;e.cancelBubble=true;}return false;}function bind(to,evt,fn){to[evt]=to[evt]||[];to[evt].push(fn);}function makeId(){return"_"+(""+Math.random()).substring(2,10);}var Clip=function(json,index,player){var self=this;var cuepoints={};var listeners={};self.index=index;if(typeof json=='string'){json={url:json};}extend(this,json,true);each(("Begin*,Start,Pause*,Resume*,Seek*,Stop*,Finish*,LastSecond,Update,BufferFull,BufferEmpty,BufferStop").split(","),function(){var evt="on"+this;if(evt.indexOf("*")!=-1){evt=evt.substring(0,evt.length-1);var before="onBefore"+evt.substring(2);self[before]=function(fn){bind(listeners,before,fn);return self;};}self[evt]=function(fn){bind(listeners,evt,fn);return self;};if(index==-1){if(self[before]){player[before]=self[before];}if(self[evt]){player[evt]=self[evt];}}});extend(this,{onCuepoint:function(points,fn){if(arguments.length==1){cuepoints.embedded=[null,points];return self;}if(typeof points=='number'){points=[points];}var fnId=makeId();cuepoints[fnId]=[points,fn];if(player.isLoaded()){player._api().fp_addCuepoints(points,index,fnId);}return self;},update:function(json){extend(self,json);if(player.isLoaded()){player._api().fp_updateClip(json,index);}var conf=player.getConfig();var clip=(index==-1)?conf.clip:conf.playlist[index];extend(clip,json,true);},_fireEvent:function(evt,arg1,arg2,target){if(evt=='onLoad'){each(cuepoints,function(key,val){if(val[0]){player._api().fp_addCuepoints(val[0],index,key);}});return false;}target=target||self;if(evt=='onCuepoint'){var fn=cuepoints[arg1];if(fn){return fn[1].call(player,target,arg2);}}if(evt=='onStart'||evt=='onUpdate'){extend(target,arg1);if(!target.duration){target.duration=arg1.metaData.duration;}else{target.fullDuration=arg1.metaData.duration;}}var ret=true;each(listeners[evt],function(){ret=this.call(player,target,arg1,arg2);});return ret;}});if(json.onCuepoint){var arg=json.onCuepoint;self.onCuepoint.apply(self,typeof arg=='function'?[arg]:arg);delete json.onCuepoint;}each(json,function(key,val){if(typeof val=='function'){bind(listeners,key,val);delete json[key];}});if(index==-1){player.onCuepoint=this.onCuepoint;}};var Plugin=function(name,json,player,fn){var listeners={};var self=this;var hasMethods=false;if(fn){extend(listeners,fn);}each(json,function(key,val){if(typeof val=='function'){listeners[key]=val;delete json[key];}});extend(this,{animate:function(props,speed,fn){if(!props){return self;}if(typeof speed=='function'){fn=speed;speed=500;}if(typeof props=='string'){var key=props;props={};props[key]=speed;speed=500;}if(fn){var fnId=makeId();listeners[fnId]=fn;}if(speed===undefined){speed=500;}json=player._api().fp_animate(name,props,speed,fnId);return self;},css:function(props,val){if(val!==undefined){var css={};css[props]=val;props=css;}json=player._api().fp_css(name,props);extend(self,json);return self;},show:function(){this.display='block';player._api().fp_showPlugin(name);return self;},hide:function(){this.display='none';player._api().fp_hidePlugin(name);return self;},toggle:function(){this.display=player._api().fp_togglePlugin(name);return self;},fadeTo:function(o,speed,fn){if(typeof speed=='function'){fn=speed;speed=500;}if(fn){var fnId=makeId();listeners[fnId]=fn;}this.display=player._api().fp_fadeTo(name,o,speed,fnId);this.opacity=o;return self;},fadeIn:function(speed,fn){return self.fadeTo(1,speed,fn);},fadeOut:function(speed,fn){return self.fadeTo(0,speed,fn);},getName:function(){return name;},_fireEvent:function(evt,arg){if(evt=='onUpdate'){var json=player._api().fp_getPlugin(name);if(!json){return;}extend(self,json);delete self.methods;if(!hasMethods){each(json.methods,function(){var method=""+this;self[method]=function(){var a=[].slice.call(arguments);var ret=player._api().fp_invoke(name,method,a);return ret=='undefined'?self:ret;};});hasMethods=true;}}var fn=listeners[evt];if(fn){fn.call(self,arg);if(evt.substring(0,1)=="_"){delete listeners[evt];}}}});};function Player(wrapper,params,conf){var
+self=this,api=null,html,commonClip,playlist=[],plugins={},listeners={},playerId,apiId,playerIndex,activeIndex,swfHeight,wrapperHeight;extend(self,{id:function(){return playerId;},isLoaded:function(){return(api!==null);},getParent:function(){return wrapper;},hide:function(all){if(all){wrapper.style.height="0px";}if(api){api.style.height="0px";}return self;},show:function(){wrapper.style.height=wrapperHeight+"px";if(api){api.style.height=swfHeight+"px";}return self;},isHidden:function(){return api&&parseInt(api.style.height,10)===0;},load:function(fn){if(!api&&self._fireEvent("onBeforeLoad")!==false){each(players,function(){this.unload();});html=wrapper.innerHTML;flashembed(wrapper,params,{config:conf});if(fn){fn.cached=true;bind(listeners,"onLoad",fn);}}return self;},unload:function(){try{if(api&&api.fp_isFullscreen()){}}catch(error){return;}if(api&&html.replace(/\s/g,'')!==''&&!api.fp_isFullscreen()&&self._fireEvent("onBeforeUnload")!==false){api.fp_close();wrapper.innerHTML=html;self._fireEvent("onUnload");api=null;}return self;},getClip:function(index){if(index===undefined){index=activeIndex;}return playlist[index];},getCommonClip:function(){return commonClip;},getPlaylist:function(){return playlist;},getPlugin:function(name){var plugin=plugins[name];if(!plugin&&self.isLoaded()){var json=self._api().fp_getPlugin(name);if(json){plugin=new Plugin(name,json,self);plugins[name]=plugin;}}return plugin;},getScreen:function(){return self.getPlugin("screen");},getControls:function(){return self.getPlugin("controls");},getConfig:function(copy){return copy?clone(conf):conf;},getFlashParams:function(){return params;},loadPlugin:function(name,url,props,fn){if(typeof props=='function'){fn=props;props={};}var fnId=fn?makeId():"_";self._api().fp_loadPlugin(name,url,props,fnId);var arg={};arg[fnId]=fn;var p=new Plugin(name,null,self,arg);plugins[name]=p;return p;},getState:function(){return api?api.fp_getState():-1;},play:function(clip){function play(){if(clip!==undefined){self._api().fp_play(clip);}else{self._api().fp_play();}}if(api){play();}else{self.load(function(){play();});}return self;},getVersion:function(){var js="flowplayer.js 3.0.5";if(api){var ver=api.fp_getVersion();ver.push(js);return ver;}return js;},_api:function(){if(!api){throw"Flowplayer "+self.id()+" not loaded. Try moving your call to player's onLoad event";}return api;},_dump:function(){console.log(listeners);},setClip:function(clip){self.setPlaylist([clip]);},getIndex:function(){return playerIndex;}});each(("Click*,Load*,Unload*,Keypress*,Volume*,Mute*,Unmute*,PlaylistReplace,Fullscreen*,FullscreenExit,Error").split(","),function(){var name="on"+this;if(name.indexOf("*")!=-1){name=name.substring(0,name.length-1);var name2="onBefore"+name.substring(2);self[name2]=function(fn){bind(listeners,name2,fn);return self;};}self[name]=function(fn){bind(listeners,name,fn);return self;};});each(("pause,resume,mute,unmute,stop,toggle,seek,getStatus,getVolume,setVolume,getTime,isPaused,isPlaying,startBuffering,stopBuffering,isFullscreen,reset,close,setPlaylist").split(","),function(){var name=this;self[name]=function(arg){if(!api){return self;}var ret=(arg===undefined)?api["fp_"+name]():api["fp_"+name](arg);return ret=='undefined'?self:ret;};});self._fireEvent=function(evt,arg0,arg1,arg2){if(conf.debug){log(arguments);}if(!api&&evt=='onLoad'&&arg0=='player'){api=api||el(apiId);swfHeight=api.clientHeight;each(playlist,function(){this._fireEvent("onLoad");});each(plugins,function(name,p){p._fireEvent("onUpdate");});commonClip._fireEvent("onLoad");}if(evt=='onLoad'&&arg0!='player'){return;}if(evt=='onError'){if(typeof arg0=='string'||(typeof arg0=='number'&&typeof arg1=='number')){arg0=arg1;arg1=arg2;}}if(evt=='onContextMenu'){each(conf.contextMenu[arg0],function(key,fn){fn.call(self);});return;}if(evt=='onPluginEvent'){var name=arg0.name||arg0;var p=plugins[name];if(p){p._fireEvent("onUpdate",arg0);p._fireEvent(arg1);}return;}if(evt=='onPlaylistReplace'){playlist=[];var index=0;each(arg0,function(){playlist.push(new Clip(this,index++,self));});}var ret=true;if(typeof arg0=='number'&&arg0<playlist.length){activeIndex=arg0;var clip=playlist[arg0];if(clip){ret=clip._fireEvent(evt,arg1,arg2);}if(!clip||ret!==false){ret=commonClip._fireEvent(evt,arg1,arg2,clip);}}var i=0;each(listeners[evt],function(){ret=this.call(self,arg0,arg1);if(this.cached){listeners[evt].splice(i,1);}if(ret===false){return false;}i++;});return ret;};function init(){if($f(wrapper)){$f(wrapper).getParent().innerHTML="";playerIndex=$f(wrapper).getIndex();players[playerIndex]=self;}else{players.push(self);playerIndex=players.length-1;}wrapperHeight=parseInt(wrapper.style.height,10)||wrapper.clientHeight;if(typeof params=='string'){params={src:params};}playerId=wrapper.id||"fp"+makeId();apiId=params.id||playerId+"_api";params.id=apiId;conf.playerId=playerId;if(typeof conf=='string'){conf={clip:{url:conf}};}if(typeof conf.clip=='string'){conf.clip={url:conf.clip};}conf.clip=conf.clip||{};if(wrapper.getAttribute("href",2)&&!conf.clip.url){conf.clip.url=wrapper.getAttribute("href",2);}commonClip=new Clip(conf.clip,-1,self);conf.playlist=conf.playlist||[conf.clip];var index=0;each(conf.playlist,function(){var clip=this;if(typeof clip=='object'&&clip.length){clip=""+clip;}if(typeof clip=='string'){clip={url:clip};}each(conf.clip,function(key,val){if(conf.clip[key]!==undefined&&typeof val!='function'){clip[key]=val;}});conf.playlist[index]=clip;clip=new Clip(clip,index,self);playlist.push(clip);index++;});each(conf,function(key,val){if(typeof val=='function'){bind(listeners,key,val);delete conf[key];}});each(conf.plugins,function(name,val){if(val){plugins[name]=new Plugin(name,val,self);}});if(!conf.plugins||conf.plugins.controls===undefined){plugins.controls=new Plugin("controls",null,self);}params.bgcolor=params.bgcolor||"#000000";params.version=params.version||[9,0];params.expressInstall='http://www.flowplayer.org/swf/expressinstall.swf';function doClick(e){if(!self.isLoaded()&&self._fireEvent("onBeforeClick")!==false){self.load();}return stopEvent(e);}html=wrapper.innerHTML;if(html.replace(/\s/g,'')!==''){if(wrapper.addEventListener){wrapper.addEventListener("click",doClick,false);}else if(wrapper.attachEvent){wrapper.attachEvent("onclick",doClick);}}else{if(wrapper.addEventListener){wrapper.addEventListener("click",stopEvent,false);}self.load();}}if(typeof wrapper=='string'){flashembed.domReady(function(){var node=el(wrapper);if(!node){throw"Flowplayer cannot access element: "+wrapper;}else{wrapper=node;init();}});}else{init();}}var players=[];function Iterator(arr){this.length=arr.length;this.each=function(fn){each(arr,fn);};this.size=function(){return arr.length;};}window.flowplayer=window.$f=function(){var instance=null;var arg=arguments[0];if(!arguments.length){each(players,function(){if(this.isLoaded()){instance=this;return false;}});return instance||players[0];}if(arguments.length==1){if(typeof arg=='number'){return players[arg];}else{if(arg=='*'){return new Iterator(players);}each(players,function(){if(this.id()==arg.id||this.id()==arg||this.getParent()==arg){instance=this;return false;}});return instance;}}if(arguments.length>1){var swf=arguments[1];var conf=(arguments.length==3)?arguments[2]:{};if(typeof arg=='string'){if(arg.indexOf(".")!=-1){var instances=[];each(select(arg),function(){instances.push(new Player(this,clone(swf),clone(conf)));});return new Iterator(instances);}else{var node=el(arg);return new Player(node!==null?node:arg,swf,conf);}}else if(arg){return new Player(arg,swf,conf);}}return null;};extend(window.$f,{fireEvent:function(id,evt,a0,a1,a2){var p=$f(id);return p?p._fireEvent(evt,a0,a1,a2):null;},addPlugin:function(name,fn){Player.prototype[name]=fn;return $f;},each:each,extend:extend});if(document.all){window.onbeforeunload=function(){$f("*").each(function(){if(this.isLoaded()){this.close();}});};}if(typeof jQuery=='function'){jQuery.prototype.flowplayer=function(params,conf){if(!arguments.length||typeof arguments[0]=='number'){var arr=[];this.each(function(){var p=$f(this);if(p){arr.push(p);}});return arguments.length?arr[arguments[0]]:new Iterator(arr);}return this.each(function(){$f(this,clone(params),conf?clone(conf):{});});};}})();(function(){var jQ=typeof jQuery=='function';function isDomReady(){if(domReady.done){return false;}var d=document;if(d&&d.getElementsByTagName&&d.getElementById&&d.body){clearInterval(domReady.timer);domReady.timer=null;for(var i=0;i<domReady.ready.length;i++){domReady.ready[i].call();}domReady.ready=null;domReady.done=true;}}var domReady=jQ?jQuery:function(f){if(domReady.done){return f();}if(domReady.timer){domReady.ready.push(f);}else{domReady.ready=[f];domReady.timer=setInterval(isDomReady,13);}};function extend(to,from){if(from){for(key in from){if(from.hasOwnProperty(key)){to[key]=from[key];}}}return to;}function asString(obj){switch(typeOf(obj)){case'string':obj=obj.replace(new RegExp('(["\\\\])','g'),'\\$1');obj=obj.replace(/^\s?(\d+)%/,"$1pct");return'"'+obj+'"';case'array':return'['+map(obj,function(el){return asString(el);}).join(',')+']';case'function':return'"function()"';case'object':var str=[];for(var prop in obj){if(obj.hasOwnProperty(prop)){str.push('"'+prop+'":'+asString(obj[prop]));}}return'{'+str.join(',')+'}';}return String(obj).replace(/\s/g," ").replace(/\'/g,"\"");}function typeOf(obj){if(obj===null||obj===undefined){return false;}var type=typeof obj;return(type=='object'&&obj.push)?'array':type;}if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};});}function map(arr,func){var newArr=[];for(var i in arr){if(arr.hasOwnProperty(i)){newArr[i]=func(arr[i]);}}return newArr;}function getHTML(p,c){var ie=document.all;var html='<object width="'+p.width+'" height="'+p.height+'"';if(ie&&!p.id){p.id="_"+(""+Math.random()).substring(9);}if(p.id){html+=' id="'+p.id+'"';}if(p.w3c||!ie){html+=' data="'+p.src+'" type="application/x-shockwave-flash"';}else{html+=' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';}html+='>';if(p.w3c||ie){html+='<param name="movie" value="'+p.src+'" />';}var e=extend({},p);e.width=e.height=e.id=e.w3c=e.src=null;for(var k in e){if(e[k]!==null){html+='<param name="'+k+'" value="'+e[k]+'" />';}}var vars="";if(c){for(var key in c){if(c[key]!==null){vars+=key+'='+(typeof c[key]=='object'?asString(c[key]):c[key])+'&';}}vars=vars.substring(0,vars.length-1);html+='<param name="flashvars" value=\''+vars+'\' />';}html+="</object>";return html;}function Flash(root,opts,flashvars){var version=flashembed.getVersion();extend(this,{getContainer:function(){return root;},getConf:function(){return conf;},getVersion:function(){return version;},getFlashvars:function(){return flashvars;},getApi:function(){return root.firstChild;},getHTML:function(){return getHTML(opts,flashvars);}});var required=opts.version;var express=opts.expressInstall;var ok=!required||flashembed.isSupported(required);if(ok){opts.onFail=opts.version=opts.expressInstall=null;root.innerHTML=getHTML(opts,flashvars);}else if(required&&express&&flashembed.isSupported([6,65])){extend(opts,{src:express});flashvars={MMredirectURL:location.href,MMplayerType:'PlugIn',MMdoctitle:document.title};root.innerHTML=getHTML(opts,flashvars);}else{if(root.innerHTML.replace(/\s/g,'')!==''){}else{root.innerHTML="<h2>Flash version "+required+" or greater is required</h2>"+"<h3>"+(version[0]>0?"Your version is "+version:"You have no flash plugin installed")+"</h3>"+"<p>Download latest version from <a href='http://www.adobe.com/go/getflashplayer'>here</a></p>";}}if(!ok&&opts.onFail){var ret=opts.onFail.call(this);if(typeof ret=='string'){root.innerHTML=ret;}}}window.flashembed=function(root,conf,flashvars){if(typeof root=='string'){var el=document.getElementById(root);if(el){root=el;}else{domReady(function(){flashembed(root,conf,flashvars);});return;}}if(!root){return;}var opts={width:'100%',height:'100%',allowfullscreen:true,allowscriptaccess:'always',quality:'high',version:null,onFail:null,expressInstall:null,w3c:false};if(typeof conf=='string'){conf={src:conf};}extend(opts,conf);return new Flash(root,opts,flashvars);};extend(window.flashembed,{getVersion:function(){var version=[0,0];if(navigator.plugins&&typeof navigator.plugins["Shockwave Flash"]=="object"){var _d=navigator.plugins["Shockwave Flash"].description;if(typeof _d!="undefined"){_d=_d.replace(/^.*\s+(\S+\s+\S+$)/,"$1");var _m=parseInt(_d.replace(/^(.*)\..*$/,"$1"),10);var _r=/r/.test(_d)?parseInt(_d.replace(/^.*r(.*)$/,"$1"),10):0;version=[_m,_r];}}else if(window.ActiveXObject){try{var _a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{_a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");version=[6,0];_a.AllowScriptAccess="always";}catch(ee){if(version[0]==6){return;}}try{_a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(eee){}}if(typeof _a=="object"){_d=_a.GetVariable("$version");if(typeof _d!="undefined"){_d=_d.replace(/^\S+\s+(.*)$/,"$1").split(",");version=[parseInt(_d[0],10),parseInt(_d[2],10)];}}}return version;},isSupported:function(version){var now=flashembed.getVersion();var ret=(now[0]>version[0])||(now[0]==version[0]&&now[1]>=version[1]);return ret;},domReady:domReady,asString:asString,getHTML:getHTML});if(jQ){jQuery.prototype.flashembed=function(conf,flashvars){return this.each(function(){flashembed(this,conf,flashvars);});};}})(); \ No newline at end of file
diff --git a/lib/flowplayer.swf b/lib/flowplayer.swf
new file mode 100644
index 00000000..61d7f652
--- /dev/null
+++ b/lib/flowplayer.swf
Binary files differ
diff --git a/themes/default/views/movie.html.php b/themes/default/views/movie.html.php
new file mode 100644
index 00000000..365faded
--- /dev/null
+++ b/themes/default/views/movie.html.php
@@ -0,0 +1,28 @@
+<?php defined("SYSPATH") or die("No direct script access.") ?>
+<script src="<?= url::file("lib/flowplayer.js") ?>" type="text/javascript"></script>
+<div id="gItem">
+ <?= $theme->photo_top() ?>
+
+ <ul id="gPager">
+ <li><?= t("%position of %total", array("position" => $position, "total" => $sibling_count)) ?></li>
+ <? if ($previous_item): ?>
+ <li><span class="ui-icon ui-icon-seek-prev"></span><a href="<?= $previous_item->url() ?>"><?= t("previous") ?></a></li>
+ <? endif ?>
+ <? if ($next_item): ?>
+ <li><a href="<?= $next_item->url() ?>"><?= t("next") ?></a><span class="ui-icon ui-icon-seek-next"></span></li>
+ <? endif ?>
+ </ul>
+
+ <a id="gMovieId-<?= $item->id ?>"
+ href="<?= $item->file_url(true) ?>"
+ style="display: block; width: <?= $item->width ?>px; height: <?= $item->height ?>px">
+ </a>
+ <script>flowplayer("gMovieId-<?= $item->id ?>", "<?= url::abs_file("lib/flowplayer.swf") ?>")</script>
+
+ <div id="gInfo">
+ <h1><?= $item->title ?></h1>
+ <div><?= $item->description ?></div>
+ </div>
+
+ <?= $theme->photo_bottom() ?>
+</div>