Welcome Guest, Not a member yet? Register   Sign In
please guide me how can i use this youtube class in codeigniter
#1

[eluser]Unknown[/eluser]
<code>
class YouTube {

function _GetVideoIdFromUrl($url) {
$parts = explode('?v=',$url);
if (count($parts) == 2) {
$tmp = explode('&',$parts[1]);
if (count($tmp)>1) {
return $tmp[0];
} else {
return $parts[1];
}
} else {
return $url;
}
}

function EmbedVideo($videoid,$width = 425,$height = 350) {
$videoid = $this->_GetVideoIdFromUrl($videoid);
return '&lt;object width="'.$width.'" height="'.$height.'"&gt;&lt;param name="movie" value="http://www.youtube.com/v/'.$videoid.'"></param><param name="wmode" value="transparent"></param>&lt;embed src="http://www.youtube.com/v/'.$videoid.'" type="application/x-shockwave-flash" wmode="transparent" width="'.$width.'" height="'.$height.'"&gt;&lt;/embed>&lt;/object&gt;';
}

function GetImg($videoid,$imgid = 1) {
$videoid = $this->_GetVideoIdFromUrl($videoid);
return "http://img.youtube.com/vi/$videoid/$imgid.jpg";
}

function ShowImg($videoid,$imgid = 1,$alt = 'Video screenshot') {
return "<img >GetImg($videoid,$imgid)."' width='130' height='97' border='0' alt='".$alt."' title='".$alt."' />";
}

}

?&gt;</code>
#2

[eluser]pistolPete[/eluser]
Did you read the userguide?
user_guide/general/creating_libraries.html
#3

[eluser]Mike Ryan[/eluser]
Hi Ali,

You could create this class as a CI library - see the documentation on writing libraries for more info.




Theme © iAndrew 2016 - Forum software by © MyBB