Skip to content

¤ The youtube_video class is a PHP utility that provides methods to extract information and generate an HTML iframe for embedding YouTube videos on webpages. It allows users to retrieve details such as video title, video description, YouTube channel name, and thumbnails.

Notifications You must be signed in to change notification settings

YR72dpi/youtube_video_class

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

youtube_video_class

I coded this class for manage youtube videos easiest on our website. If you have a question or just want talk with me, you can come on my Twitter.

How to use ?

Start by initialising the class:

$yt = new youtube_video('https://www.youtube.com/watch?v=FTQbiNvZqaY');

Is_vYT()

It's the only static function. This function return true if the url is a youtube url. Return true

if (youtube_video::Is_vYT('https://www.youtube.com/watch?v=FTQbiNvZqaY')) {
	# code...
}

Return false

if (youtube_video::Is_vYT('https://www.vimeo.com/watch?v=FTQbiNvZqaY')) {
	# code...
}

get_url()

Return your url.

$yt->get_url();

Return https://www.youtube.com/watch?v=FTQbiNvZqaY

get_id()

Return the video id.

$yt->get_id();

Return FTQbiNvZqaY

get_title()

Return the video title.

$yt->get_title();

Return Toto - Africa (Official Music Video)

get_urlChannel()

Return the channel url.

$yt->get_urlChannel();

Return https://www.youtube.com/user/TotoVEVO

get_nameChannel()

Return the channel name.

$yt->get_nameChannel();

Return TotoVEVO

get_Thumbnail ()

Return an array with the video Thumbnail and other images from the video.

$yt->get_Thumbnail();

Return an array with 8 differents images If you write this :

$yt->get_Thumbnail()[0];

Return https://img.youtube.com/vi/FTQbiNvZqaY/maxresdefault.jpg

Iframe()

$yt->iframe();

Return an iframe of the video

Iframe setting

In this class, there is a public variable named $iframe_param. You need to use it for set the iframe. For example, if you need to change the iframe width, you can do like that :

$yt->iframe_param["width"] = '160px';

There are 12 parameters that you can set and all are commented with their default value.

public $iframe_param = [
		'width'          => '560px', // width (or indicator css like "%")
		// Default value : 560px
		'height'         => '315px', // height (or indicateur css comme les "%")
		// Default value : 315px
		"rel"            => '1',     // Displays video suggestions (or 0 for don't display)
		// Default value : 1
		"controls"       => '1',     // Shows the controls (or 0 for don't display)
		// Default value : 1
		"showinfo"       => '1',     // Displays information (or 0 for don't display)
		// Default value : 1
		"cookies"        => '1',     // Mode using cookies (or 0 for don't use cookies)
		// Default value : 1
		"autoplay"       => '0',     // The video doesn't start alone (1 to start alone)
		// Default value : 0
		"color"          => 'red',   // Player color (red or white)
		// Default value : red
		"start"          => '0',     // Start the video at 0 seconds (or start at 20 seconds by putting 20)
		// Default value : 0
		"modestbranding" => '0',     // Displays the YouTube logo on the control banner (or 1 to don't display it)
		// Default value : 0
		"fs"             => '1',     // Present the full screen button (or 0 to don't display it)
		// Default value : 1
		"cc_load_policy" => "1"      // Display subtitles, even if the user has disabled them
		// Default value : 1
	];

About

¤ The youtube_video class is a PHP utility that provides methods to extract information and generate an HTML iframe for embedding YouTube videos on webpages. It allows users to retrieve details such as video title, video description, YouTube channel name, and thumbnails.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages