diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-02-25 05:27:29 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-02-25 05:27:29 +0000 |
commit | 515c081f794c0e020241956f291381361e28489a (patch) | |
tree | 3c1f4a153d046db9f3a4a39df4954bbc33a227f1 | |
parent | 585ea819579405bbfe772d2e7fa647f54d5a17e2 (diff) |
Add support MP4 movies also. Flowplayer supports them and can stream
them using the h264streaming plugin. Everything else is a fairly
minor change.
-rw-r--r-- | core/SimpleUploader.swf | bin | 301344 -> 301349 bytes | |||
-rw-r--r-- | core/controllers/simple_uploader.php | 14 | ||||
-rw-r--r-- | core/helpers/graphics.php | 1 | ||||
-rw-r--r-- | core/helpers/movie.php | 2 | ||||
-rw-r--r-- | core/helpers/photo.php | 11 | ||||
-rw-r--r-- | core/models/item.php | 26 | ||||
-rw-r--r-- | lib/flowplayer.h264streaming.swf | bin | 0 -> 78371 bytes | |||
-rw-r--r-- | modules/local_import/controllers/local_import.php | 4 | ||||
-rw-r--r-- | themes/default/views/movie.html.php | 8 |
9 files changed, 40 insertions, 26 deletions
diff --git a/core/SimpleUploader.swf b/core/SimpleUploader.swf Binary files differindex 2be9841f..152917b1 100644 --- a/core/SimpleUploader.swf +++ b/core/SimpleUploader.swf diff --git a/core/controllers/simple_uploader.php b/core/controllers/simple_uploader.php index 4e2be4c8..b56bce16 100644 --- a/core/controllers/simple_uploader.php +++ b/core/controllers/simple_uploader.php @@ -46,19 +46,19 @@ 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,flv]"); + $file_validation->add_rules("file", "upload::valid", "upload::type[gif,jpg,png,flv,mp4]"); if ($file_validation->validate()) { - $temp_filename = upload::save("file"); + $temp_filename = upload::save("file"); $title = substr(basename($temp_filename), 10); // Skip unique identifier Kohana adds $path_info = pathinfo($temp_filename); - if ($path_info["extension"] == "flv") { + if (in_array(strtolower($path_info["extension"]), array("flv", "mp4"))) { $movie = movie::create($album, $temp_filename, $title, $title); - log::success("content", t("Added a movie"), html::anchor("movies/$movie->id", - t("view movie"))); + log::success("content", t("Added a movie"), + html::anchor("movies/$movie->id", t("view movie"))); } else { $photo = photo::create($album, $temp_filename, $title, $title); - log::success("content", t("Added a photo"), html::anchor("photos/$photo->id", - t("view photo"))); + log::success("content", t("Added a photo"), + html::anchor("photos/$photo->id", t("view photo"))); } } } diff --git a/core/helpers/graphics.php b/core/helpers/graphics.php index 92e1c3f7..d30701a0 100644 --- a/core/helpers/graphics.php +++ b/core/helpers/graphics.php @@ -107,6 +107,7 @@ class graphics_Core { foreach ($ops as $target => $output_file) { if ($input_item->is_movie()) { // Convert the movie to a JPG first + $output_file = preg_replace("/...$/", "jpg", $output_file); movie::extract_frame($input_file, $output_file); $working_file = $output_file; } else { diff --git a/core/helpers/movie.php b/core/helpers/movie.php index 9941fcee..9a93afbf 100644 --- a/core/helpers/movie.php +++ b/core/helpers/movie.php @@ -60,7 +60,7 @@ class movie_Core { $movie->owner_id = $owner_id; $movie->width = $movie_info[0]; $movie->height = $movie_info[1]; - $movie->mime_type = "video/x-flv"; + $movie->mime_type = strtolower($pi["extension"]) == "mp4" ? "video/mp4" : "video/x-flv"; $movie->thumb_dirty = 1; $movie->resize_dirty = 1; diff --git a/core/helpers/photo.php b/core/helpers/photo.php index 9b773dc4..aab72a87 100644 --- a/core/helpers/photo.php +++ b/core/helpers/photo.php @@ -44,13 +44,6 @@ class photo_Core { } $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 $pi = pathinfo($name); @@ -60,7 +53,7 @@ class photo_Core { } $photo = ORM::factory("item"); - $photo->type = $type; + $photo->type = "photo"; $photo->title = $title; $photo->description = $description; $photo->name = $name; @@ -109,7 +102,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,flv]"); + $group->upload("file")->label(t("File"))->rules("required|allow[jpg,png,gif,flv,mp4]"); $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 329f9c43..cc242abf 100644 --- a/core/models/item.php +++ b/core/models/item.php @@ -180,8 +180,15 @@ class Item_Model extends ORM_MPTT { * photo: /var/albums/album1/photo.thumb.jpg */ public function thumb_path() { - return VARPATH . "thumbs/" . $this->relative_path() . - ($this->is_album() ? "/.album.jpg" : ""); + $base = VARPATH . "thumbs/" . $this->relative_path(); + if ($this->is_photo()) { + return $base; + } else if ($this->is_album()) { + return $base . "/.album.jpg"; + } else if ($this->is_movie()) { + // Replace the extension with jpg + return preg_replace("/...$/", "jpg", $base); + } } /** @@ -189,10 +196,17 @@ class Item_Model extends ORM_MPTT { * photo: http://example.com/gallery3/var/albums/album1/photo.thumb.jpg */ public function thumb_url($full_uri=true) { - return ($full_uri ? - url::abs_file("var/thumbs/" . $this->relative_path()) : - url::file("var/thumbs/" . $this->relative_path())) . - ($this->is_album() ? "/.album.jpg" : ""); + $base = ($full_uri ? + url::abs_file("var/thumbs/" . $this->relative_path()) : + url::file("var/thumbs/" . $this->relative_path())); + if ($this->is_photo()) { + return $base; + } else if ($this->is_album()) { + return $base . "/.album.jpg"; + } else if ($this->is_movie()) { + // Replace the extension with jpg + return preg_replace("/...$/", "jpg", $base); + } } /** diff --git a/lib/flowplayer.h264streaming.swf b/lib/flowplayer.h264streaming.swf Binary files differnew file mode 100644 index 00000000..13c17a92 --- /dev/null +++ b/lib/flowplayer.h264streaming.swf diff --git a/modules/local_import/controllers/local_import.php b/modules/local_import/controllers/local_import.php index 80dc0215..12f548fc 100644 --- a/modules/local_import/controllers/local_import.php +++ b/modules/local_import/controllers/local_import.php @@ -86,7 +86,7 @@ class Local_Import_Controller extends Controller { } else { $parent = $album; } - } else if ($pathinfo["extension"] == "flv") { + } else if (in_array($pathinfo["extension"], array("flv", "mp4")) { $movie = movie::create($parent, $source_path, basename($source_path), basename($source_path)); log::success("content", t("Added a movie"), @@ -115,7 +115,7 @@ class Local_Import_Controller extends Controller { $extension = strtolower(substr(strrchr($file, '.'), 1)); // Make sure the file is readable if (is_readable($full_path) && - in_array($extension, array("IMAGETYPE_GIF", "JPEG", "jpg", "PNG", "flv"))) { + in_array($extension, array("gif", "jpeg", "jpg", "png", "flv", "mp4"))) { $file_list[$file] = array("path" => $full_path, "is_dir" => false); } } diff --git a/themes/default/views/movie.html.php b/themes/default/views/movie.html.php index 365faded..3f88c3fd 100644 --- a/themes/default/views/movie.html.php +++ b/themes/default/views/movie.html.php @@ -17,7 +17,13 @@ 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> + <script> + flowplayer("gMovieId-<?= $item->id ?>", "<?= url::abs_file("lib/flowplayer.swf") ?>", { + plugins: { + h264streaming: { url: "<?= url::abs_file("lib/flowplayer.h264streaming.swf") ?>" } + } + }) + </script> <div id="gInfo"> <h1><?= $item->title ?></h1> |