]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Watch working for Vimeo and Youtube.
authorSem <sembrestels@riseup.net>
Sun, 6 Nov 2011 22:28:09 +0000 (23:28 +0100)
committerSem <sembrestels@riseup.net>
Sun, 6 Nov 2011 22:28:09 +0000 (23:28 +0100)
lib/videolist.php
views/default/object/videolist_item.php
views/default/videolist/watch/metacafe.php [new file with mode: 0644]
views/default/videolist/watch/vimeo.php [new file with mode: 0644]
views/default/videolist/watch/youtube.php [new file with mode: 0644]

index 18745dfd1ba9f99881f4d851ab776ed2ad2ffb15..03b6e2760988798e03314cf736c74daba8a03f8f 100644 (file)
@@ -20,7 +20,7 @@ function videolist_parseurl_youtube($url) {
        
        return array(
                'domain' => $domain,
-               'videoid' => $hash,
+               'video_id' => $hash,
        );
 }
 
@@ -34,7 +34,7 @@ function videolist_parseurl_vimeo($url) {
 
        return array(
                'domain' => $domain,
-               'videoid' => $hash,
+               'video_id' => $hash,
        );
 }
 
@@ -50,7 +50,7 @@ function videolist_parseurl_metacafe($url) {
 
        return array(
                'domain' => $domain,
-               'videoid' => $hash,
+               'video_id' => $hash,
        );
 }
 
@@ -71,30 +71,31 @@ function videolist_parseurl($url){
 
 function videolist_get_data($video_parsed_url) {
        $site = $video_parsed_url['site'];
-       $videoid = $video_parsed_url['videoid'];
+       $video_id = $video_parsed_url['video_id'];
        switch($site){
-               case YOUTUBE: return videolist_get_data_youtube($videoid);
-               case VIMEO: return videolist_get_data_vimeo($videoid);
-               case METACAFE: return videolist_get_data_metacafe($videoid);
+               case YOUTUBE: return videolist_get_data_youtube($video_id);
+               case VIMEO: return videolist_get_data_vimeo($video_id);
+               case METACAFE: return videolist_get_data_metacafe($video_id);
                default: return array();
        }
 }
 
 
-function videolist_get_data_youtube($videoid){
-       $buffer = file_get_contents('http://gdata.youtube.com/feeds/api/videos/'.$videoid);
+function videolist_get_data_youtube($video_id){
+       $buffer = file_get_contents('http://gdata.youtube.com/feeds/api/videos/'.$video_id);
        $xml = new SimpleXMLElement($buffer);
        
        return array(
                'title' => sanitize_string($xml->title),
                'description' => sanitize_string($xml->content),
-               'icon' => "http://img.youtube.com/vi/$videoid/default.jpg",
+               'icon' => "http://img.youtube.com/vi/$video_id/default.jpg",
+               'video_id' => $video_id,
                'videotype' => 'youtube',
        );
 }
 
-function videolist_get_data_vimeo($videoid){
-       $buffer = file_get_contents("http://vimeo.com/api/v2/video/$videoid.xml");
+function videolist_get_data_vimeo($video_id){
+       $buffer = file_get_contents("http://vimeo.com/api/v2/video/$video_id.xml");
        $xml = new SimpleXMLElement($buffer);
        
        $videos = $xml->children();
@@ -104,12 +105,13 @@ function videolist_get_data_vimeo($videoid){
                'title' => sanitize_string($video->title),
                'description' => sanitize_string($video->description),
                'icon' => sanitize_string($video->thumbnail_medium),
+               'video_id' => $video_id,
                'videotype' => 'vimeo',
        );
 }
 
-function videolist_get_data_metacafe($videoid){ //FIXME
-       $buffer = file_get_contents("http://www.metacafe.com/api/item/$videoid");
+function videolist_get_data_metacafe($video_id){ //FIXME
+       $buffer = file_get_contents("http://www.metacafe.com/api/item/$video_id");
        $xml = new SimpleXMLElement($buffer);
        
        $children = $xml->children();
@@ -121,6 +123,7 @@ function videolist_get_data_metacafe($videoid){ //FIXME
                'title' => $channel->title,
                'description' => $channel->description,
                'icon' => $matches[1],
+               'video_id' => $video_id,
                'videotype' => 'metacafe',
        );
 }
index 35946579beaa42dacad0d527fe26c2b1845554d3..827efb48fd5f231bb9c881a178c3250242dd5905 100644 (file)
@@ -51,40 +51,31 @@ if(!$full_view) {
                echo "<div class='video_entity'>".elgg_view_listing($icon, $info)."</div>";
        }
 } else {
-       $videodiv = '';
+       $html = '';
        $width = "600";
        $height = "400";
-       $file = $vars['entity'];
+       $entity = $vars['entity'];
        
-       $videos = get_entity($vars['entity']);
-       $title = $videos->title;
-       $url = $videos->url;
-       $videoid = $videos->video_id;
-       $tags = $videos->tags;
+       $title = $entity->title;
+       $url = $entity->video_url;
+       $video_id = $entity->video_id;
        
-       $videodiv .= "<div class='video_view'>";
-                                
-       // display any tags for the Video
-       if (!empty($tags)) {
-               $videodiv .= "<p class='tags margin_none'>";
-               $videodiv .= elgg_view('output/tags',array('value' => $tags));
-               $videodiv .= "</p>";
-       }
-       
-       if ($videos->videotype == "youtube") {
-               $videodiv .= "<br /><object width=\"$width\" height=\"$height\"><param name=\"movie\" value=\"http://{$url}&hl=en&fs=1&showinfo=0&auoplay=1\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"http://{$url}&hl=en&fs=1&showinfo=0&autoplay=1\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" width=\"$width\" height=\"$height\" wmode=\"transparent\"></embed></object>";
-       } else if($videos->videotype == "metacafe"){
-               $videoid_id = $videoid;
-               $path = explode("/", $videos->thumbnail);
-               $path = array_reverse($path);
-               $thumbnailArray = explode(".", $path[0]);
-               $videoid = $videoid_id."/".$thumbnailArray[0].".swf";
-               $videodiv .= "<br /><embed src=\"http://www.metacafe.com/fplayer/".$videoid."\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" allowscriptaccess=\"always\" width=\"$width\" height=\"$height\" wmode=\"transparent\" name=\"Metacafe_".$videoid_id."\"></embed>";
-       } else if($videos->videotype == "vimeo") {
-               $videodiv .= "<br /><object width=\"$width\" height=\"$height\"><param name=\"allowfullscreen\" value=\"true\" /><param name=\"allowscriptaccess\" value=\"always\" /><param name=\"wmode\" value=\"transparent\"></param><param name=\"movie\" value=\"http://vimeo.com/moogaloop.swf?clip_id=".$videoid."&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1\" /><embed src=\"http://vimeo.com/moogaloop.swf?clip_id=".$videoid."&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" allowscriptaccess=\"always\" width=\"$width\" height=\"$height\" wmode=\"transparent\"></embed></object>";
+       $html .= "<div class='video_view'>";
+
+       if (!empty($entity->tags)) {
+               $html .= "<p class='tags margin_none'>";
+               $html .= elgg_view('output/tags',array('value' => $entity->tags));
+               $html .= "</p>";
        }
 
-       $videodiv .= "</div>";
-       $videodiv .= elgg_view_comments($videos);
-       print $videodiv;
+       $html .= elgg_view("videolist/watch/{$entity->videotype}", array(
+               'video_id' => $entity->video_id,
+               'width' => $width,
+               'height' => $height,
+       ));
+
+
+       $html .= "</div>";
+       $html .= elgg_view_comments($videos);
+       echo $html;
 }
diff --git a/views/default/videolist/watch/metacafe.php b/views/default/videolist/watch/metacafe.php
new file mode 100644 (file)
index 0000000..cfa5e02
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+
+/* TODO
+$video_id = $vars['video_id'];
+$width = $vars['width'];
+$height = $vars['height'];
+
+$path = explode("/", $videos->thumbnail);
+$path = array_reverse($path);
+$thumbnailArray = explode(".", $path[0]);
+$video_id = $video_id."/".$thumbnailArray[0].".swf";
+
+echo "<br />
+<embed src=\"http://www.metacafe.com/fplayer/".$video_id."\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" allowscriptaccess=\"always\" width=\"$width\" height=\"$height\" wmode=\"transparent\" name=\"Metacafe_".$video_id."\"></embed>";
+*/
diff --git a/views/default/videolist/watch/vimeo.php b/views/default/videolist/watch/vimeo.php
new file mode 100644 (file)
index 0000000..caf34c1
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+
+$video_id = $vars['video_id'];
+$width = $vars['width'];
+$height = $vars['height'];
+
+echo "<iframe src=\"http://player.vimeo.com/video/$video_id?byline=0&amp;color=e11531&amp;autoplay=1\" width=\"$width\" height=\"$height\" frameborder=\"0\" webkitAllowFullScreen allowFullScreen></iframe>";
diff --git a/views/default/videolist/watch/youtube.php b/views/default/videolist/watch/youtube.php
new file mode 100644 (file)
index 0000000..4b62aab
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+
+$video_id = $vars['video_id'];
+$width = $vars['width'];
+$height = $vars['height'];
+
+echo "<iframe width=\"$width\" height=\"$height\" src=\"https://www.youtube-nocookie.com/embed/$video_id\" frameborder=\"0\" allowfullscreen></iframe>";