From 0adeee109cf8d8517f3a890105f5b46459495204 Mon Sep 17 00:00:00 2001 From: Sem Date: Sun, 6 Nov 2011 23:28:09 +0100 Subject: Watch working for Vimeo and Youtube. --- lib/videolist.php | 31 ++++++++++-------- views/default/object/videolist_item.php | 51 ++++++++++++------------------ views/default/videolist/watch/metacafe.php | 15 +++++++++ views/default/videolist/watch/vimeo.php | 7 ++++ views/default/videolist/watch/youtube.php | 7 ++++ 5 files changed, 67 insertions(+), 44 deletions(-) create mode 100644 views/default/videolist/watch/metacafe.php create mode 100644 views/default/videolist/watch/vimeo.php create mode 100644 views/default/videolist/watch/youtube.php diff --git a/lib/videolist.php b/lib/videolist.php index 18745dfd1..03b6e2760 100644 --- a/lib/videolist.php +++ b/lib/videolist.php @@ -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', ); } diff --git a/views/default/object/videolist_item.php b/views/default/object/videolist_item.php index 35946579b..827efb48f 100644 --- a/views/default/object/videolist_item.php +++ b/views/default/object/videolist_item.php @@ -51,40 +51,31 @@ if(!$full_view) { echo "
".elgg_view_listing($icon, $info)."
"; } } 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 .= "
"; - - // display any tags for the Video - if (!empty($tags)) { - $videodiv .= "

"; - $videodiv .= elgg_view('output/tags',array('value' => $tags)); - $videodiv .= "

"; - } - - if ($videos->videotype == "youtube") { - $videodiv .= "
"; - } 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 .= "
"; - } else if($videos->videotype == "vimeo") { - $videodiv .= "
"; + $html .= "
"; + + if (!empty($entity->tags)) { + $html .= "

"; + $html .= elgg_view('output/tags',array('value' => $entity->tags)); + $html .= "

"; } - $videodiv .= "
"; - $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 .= "
"; + $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 index 000000000..cfa5e02a4 --- /dev/null +++ b/views/default/videolist/watch/metacafe.php @@ -0,0 +1,15 @@ +thumbnail); +$path = array_reverse($path); +$thumbnailArray = explode(".", $path[0]); +$video_id = $video_id."/".$thumbnailArray[0].".swf"; + +echo "
+"; +*/ diff --git a/views/default/videolist/watch/vimeo.php b/views/default/videolist/watch/vimeo.php new file mode 100644 index 000000000..caf34c1f4 --- /dev/null +++ b/views/default/videolist/watch/vimeo.php @@ -0,0 +1,7 @@ +"; diff --git a/views/default/videolist/watch/youtube.php b/views/default/videolist/watch/youtube.php new file mode 100644 index 000000000..4b62aabbc --- /dev/null +++ b/views/default/videolist/watch/youtube.php @@ -0,0 +1,7 @@ +"; -- cgit v1.2.3