Гледане на клипове от различни сайтове.
Сега ще ви запозная с един код, чрез който можете да гледате клипове на вашия сайт, като просто копирате линка на клипа. Известните сайтове, от които можете да гледате видео от тази система са: YouTube, Google, Clipfish, MyVideo,VideoTube и MySpaceTV. Ето го и него:

Правите си файл с име "playvideo.php" и в него добавяте това:
<?php

/**
* playvideo.php (php4)
* Автор: Velikcho
*/


class VideoportalPlayer
{
//Тук задавате височината и ширината//
var $width = 425;
var $height = 350;


function _setReplace($posting, $results, $tmpl_player, $index=1)
{
foreach($results as $item)
$posting = str_replace($item[0], str_replace('[ID]', $item[$index], $tmpl_player), $posting);
return $posting;
}


function getYoutube($posting)
{
//Това са адресите, които са дадени за пример.
//Тук изпълняваме функцията за гледане от Youtube & uk.Youtube.com
#@http://www.youtube.com/watch?v=fvjT5FrWpS0
#@http://uk.youtube.com/watch?v=3_1Y8UoLIu4
$tmpl_player= '<object width="'.$this->width.'" height="'.$this->height.'">
<param name="movie" value="http://www.youtube.com/v/[ID]"></param>
<param name="wmode" value="transparent"></param>
<embed src="http://www.youtube.com/v/[ID]" type="application/x-shockwave-flash" wmode="transparent" width="'.$this->width.'" height="'.$this->height.'"></embed>
</object>';
preg_match_all('/@http:\/\/(www\.|uk\.)?youtube\.com\/watch\?v=([\d\w-_]+)/', $posting, $results, PREG_SET_ORDER);
if($results)
$posting = $this->_setReplace($posting, $results, $tmpl_player, $index=2);
return $posting;
}


function getGoogle($posting)
{
//Тук изпълняваме функцията за гледане от video.google.com
#@http://video.google.com/googleplayer.swf?docId=-2205197918273229623
#@http://video.google.com/videoplay?docid=-2205197918273229623
$tmpl_player= '<object type="application/x-shockwave-flash" data="http://video.google.com/googleplayer.swf?docId=[ID]" height="'.$this->height.'" width="'.$this->width.'">
<param name="movie" value="http://video.google.com/googleplayer.swf?docId=[ID]">
</object>';
preg_match_all('/@http:\/\/video\.google\.com\/(googleplayer\.swf|videoplay)\?doc[Ii]d=([\d-]+)/', $posting, $results, PREG_SET_ORDER); #funny one google :)
if($results)
$posting = $this->_setReplace($posting, $results, $tmpl_player, $index=2);
return $posting;
}


function getClipfish($posting)
{
//Тук изпълняваме функцията за гледане от clipfish.de
#@http://www.clipfish.de/player.php?videoid=MTk0ODU4fDEw
$tmpl_player = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'.$this->width.'" height="'.$this->height.'" id="player" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="http://www.clipfish.de/videoplayer.swf?as=0&videoid=[ID]&r=1" />
<param name="wmode" value="transparent">
<param name="quality" value="high" />
<param name="bgcolor" value="#999999" />
<embed src="http://www.clipfish.de/videoplayer.swf?as=0&videoid=[ID]&r=1" quality="high" bgcolor="#999999" width="'.$this->width.'" height="'.$this->height.'" name="player" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
</object>';
preg_match_all('/@http:\/\/www\.clipfish\.de\/player\.php\?videoid=([\d\w-_]+)/', $posting, $results, PREG_SET_ORDER);
if($results)
$posting = $this->_setReplace($posting, $results, $tmpl_player);
return $posting;
}


function getMyvideo($posting)
{
//Тук изпълняваме функцията за гледане от myvideo.de
#@http://www.myvideo.de/watch/65741
$tmpl_player = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="'.$this->width.'" height="'.$this->height.'"><param name="movie" value="http://www.myvideo.de/movie/[ID]"></param><embed src="http://www.myvideo.de/movie/[ID]" width="'.$this->width.'" height="'.$this->height.'" type="application/x-shockwave-flash"></embed></object>';
preg_match_all('/@http:\/\/www\.myvideo\.de\/watch\/([\d]+)/', $posting, $results, PREG_SET_ORDER);
if($results)
$posting = $this->_setReplace($posting, $results, $tmpl_player);
return $posting;
}


function getVideotube($posting)
{
//Тук изпълняваме функцията за гледане от videotube.de
#@http://videotube.de/watch/31603
$tmpl_player = '<object type="application/x-shockwave-flash" data="http://www.videotube.de/ci/flash/videotube_player_4.swf?videoId=[ID]&svsf=0&lang=german&host=www.videotube.de" width="'.$this->width.'" height="'.$this->height.'" wmode="transparent"><param name="movie" value="http://www.videotube.de/ci/flash/videotube_player_4.swf?videoId=[ID]&svsf=0&lang=german&host=www.videotube.de" /></object>';
preg_match_all('/@http:\/\/videotube\.de\/watch\/([\d]+)/', $posting, $results, PREG_SET_ORDER);
if($results)
$posting = $this->_setReplace($posting, $results, $tmpl_player);
return $posting;
}


function getDailymotion($posting)
{
#Тази функция е забранена, защото немога да я поставя тук
#Проблемът е че ИД-то от УРЛ-а и ИД-то от клипчето не съвпадат.
return False;
}


function getMyspacetv($posting)
{
//Тук изпълняваме функцията за гледане от myspacetv.com & vids.myspace.com
#@http://myspacetv.com/index.cfm?fuseaction=vids.individual&videoid=784348108
#@http://vids.myspace.com/index.cfm?fuseaction=vids.individual&VideoID=4592484
#contributed by Mariano Alborés
$tmpl_player = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'.$this->width.'" height="'.$this->height.'" id="player" align="middle"><embed src="http://lads.myspace.com/videos/myspacetv_vplayer0005.swf?fuseaction=vids.individual&videoid=[ID]" width="'.$this->width.'" height="'.$this->height.'" flashvars="m=[ID]&type="application/x-shockwave-flash"></embed></object>';
preg_match_all('/@http:\/\/(myspacetv|vids\.myspace)\.com\/index\.cfm\?fuseaction=vids.individual&(videoid|VideoID)=([\d\w-_]+)/', $posting, $results, PREG_SET_ORDER);
print $result;
if($results)
$posting = $this->_setReplace($posting, $results, $tmpl_player, $index=3);
return $posting;
}


function getAbcnews($posting)
{
#@http://ugv.abcnews.go.com/player.aspx?id=570913
$tmp_player = '<embed width="'.$this->width.'" height="'.$this->height.'" wmode="transparent" flashvars="file=http://ugv.abcnews.go.com/ChannelRssHandler.ashx%3fcontentItemID%3d[ID]%26mi%3d1&autostart=false&overstretch=false&LinkOnScreenClick=0&InitialVolume=40" quality="high" name="mpl" id="mpl" src="http://ugv.abcnews.go.com/dbox/3/flvplayer_abc_small.swf" type="application/x-shockwave-flash"/>';
preg_match_all('/@http:\/\/ugv\.abcnews\.go\.com\/player\.aspx\?id=([\d]+)/', $posting, $results, PREG_SET_ORDER);
if ($results)
$posting = $this->_setReplace($posting, $results, $tmp_player, $index=1);
return $posting;
}

}

?>


Сега направете нов документ с име "index.php" (може и друго) и добавете следния код:
<?php
//Тук на мястото на $content.="" слагате адреса на клипа, който искате да е на страницата Например:
//$content.= "http://www.youtube.com/watch?v=fvjT5FrWpS0 <br />"; - Между " и " пишете адреса на клипа.
//$content.= "@http://www.youtube.com/watch?v=fvjT5FrWpS0 <br/>"; - А тук пишете информация например.

$content.= "<strong>Youtube (+ uk.youtube.com)</strong><br />";
$content.= "http://www.youtube.com/watch?v=fvjT5FrWpS0 <br />";
$content.= "@http://www.youtube.com/watch?v=fvjT5FrWpS0 <br/>";
$content.="http://uk.youtube.com/watch?v=3_1Y8UoLIu4 <br />";
$content.="@http://uk.youtube.com/watch?v=3_1Y8UoLIu4 <br />";

$content.= "<strong>Google (googleplayer + videoplayer)</strong><br />";
$content.= "http://video.google.com/googleplayer.swf?docId=-2205197918273229623 <br />";
$content.= "@http://video.google.com/googleplayer.swf?docId=-2205197918273229623 <br />";
$content.= "http://video.google.com/videoplay?docid=-2205197918273229623 <br />";
$content.= "@http://video.google.com/videoplay?docid=-2205197918273229623 <br />";

$content.= "<strong>myspace (myspacetv.com + vids.myspace.com)</strong><br />";
$content.="http://myspacetv.com/index.cfm?fuseaction=vids.individual&videoid=784348108 <br />";
$content.="@http://myspacetv.com/index.cfm?fuseaction=vids.individual&videoid=784348108 <br />";
$content.="http://vids.myspace.com/index.cfm?fuseaction=vids.individual&VideoID=4592484 <br />";
$content.="@http://vids.myspace.com/index.cfm?fuseaction=vids.individual&VideoID=4592484 <br />";

$content.= "<strong>clipfish.de</strong><br />";
$content.= "http://www.clipfish.de/player.php?videoid=MTk0ODU4fDEw <br />";
$content.= "@http://www.clipfish.de/player.php?videoid=MTk0ODU4fDEw <br />";

$content.= "<strong>myvideo.de</strong><br />";
$content.="http://www.myvideo.de/watch/1651790<br />";
$content.="@http://www.myvideo.de/watch/1651790<br />";

$content.= "<strong>videotube.de</strong><br />";
$content.="http://videotube.de/watch/31603<br />";
$content.="@http://videotube.de/watch/31603<br />";

require_once('playvideo.php');

$VideoportalPlayer = new VideoportalPlayer;

$content = $VideoportalPlayer->getYoutube($content);
$content = $VideoportalPlayer->getGoogle($content);
$content = $VideoportalPlayer->getClipfish($content);
$content = $VideoportalPlayer->getMyvideo($content);
$content = $VideoportalPlayer->getVideotube($content);
$content = $VideoportalPlayer->getMyspacetv($content);

//Чрез тази команда извеждаме информацията, която сте задали.
print $content;

?>


И това е :) Лесно а? Благодаря на Стоянски за демото. ДЕМО


/ Трябва да сте регистриран за да напишете коментар /