PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Nemanja Avramovic   YouTube   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example of usage
Class: YouTube
Embed YouTube videos in Web pages
Author: By
Last change: fixed examples to reflect new version of the class
Date: 14 years ago
Size: 1,169 bytes
 

Contents

Class file image Download
<?php

include "youtube.class.php";

$jutjub = new YouTube('http://www.youtube.com/watch?v=M_bvT-DGcWw');

//Show image of this video. This function accepts three parameters, but none is required.
// 1st: Video url or video ID displayed on youtube (http://www.youtube.com/watch?v=VIDEO_ID) - if omitted (null), one used in constructor will be used
// 2nd: Image ID (1, 2 or 3) - default: 1
// 3rd: Image ALT/TITLE text - default: Video screenshot
echo $jutjub->ShowImg() . ' ' . $jutjub->ShowImg('http://www.youtube.com/watch?v=M_bvT-DGcWw', 2) . ' ' . $jutjub->ShowImg('M_bvT-DGcWw', 3, 'Custom title');

//new line : )
echo "<br /><br />\n";

//Embed video on web page. This function accepts three parameters, but none is required.
// 1st: Video id or video url displayed on youtube (http://www.youtube.com/watch?v=VIDEO_ID) - if omitted (null), one used in constructor will be used
// 2nd: Video width in pixels - default: 425
// 3rd: Video height in pixels - default: 344
echo $jutjub->EmbedVideo();

//new line : )
echo "<br /><br />\n";

//Extract video ID
echo "Video ID: " . YouTube::parseURL('http://www.youtube.com/watch?v=M_bvT-DGcWw&mode=user&search=');

?>