I never worked with video at all.
Just asking how is it possible to enable members in my site to upload videos.
I have seen in some site example Tagged.com,there videos got Youtube player)))how is possible to play tube videos in my website.
Its a Social Network web

Yes. Look up the YT API, but be aware it's a pig. You can play the videos just by embedding code (or using the API again).

A good alternative to YT is Vimeo. I highly recommend it - it has its own API as well.

i checked the YT application,but didn`t understand.
let me explain the way i want may be u may comment,I want members in my website to be able to copy the you the Youtube URL video and paste it in my website.
then when displaying the videos,to display with the username of the person...I think mysql must be inluded But How??
thx.

Give the users two fields - one to identify the user and one for the embedded object code from the youtube video - stick 'em both into a database and you can then read the database to output the listings.

You could also stick the youtube homepage in an iframe so the users can go to their video and copy and paste the embedded object code without switching pages.

i want to display the thumbnail of the video,then when someone click on it it will show the original version of Video...so how about this??

Can I suggest that you don't allow the pasting of embedded code. It could be really nasty. Just the url should do - strip the video id from the querystring and use that to insert into a ready made embed code, eg.

get youtube video id from your db and place into $code variable;

<object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/[B]<?php echo $code;?>[/B]&hl=en&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/[B]<?php echo $code;?>[/B]&hl=en&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object>

At least this way you don't get any horrible results - validate/clean/strip the url before sending to the db.

The only thing you need to be saving to db is the id, e.g. "JC1D0OQNZg4" out of "http: //www .youtube.com/watch?v=JC1D0OQNZg4".

This way you get to control the colour scheme, the video dimensions etc. I really don't know if this technique will mess with HD implementation.

now the problem is how i`m going to remove http: //www .youtube.com/watch?v= out of
"http: //www .youtube.com/watch?v=JC1D0OQNZg4".

Try this:

<?php
	/* 
	 * Retrieve the video ID from a YouTube video URL
	 * @param $ytURL The full YouTube URL from which the ID will be extracted
	 * @return $ytvID The YouTube video ID string
	 */
	function getYTid($ytURL) {
		
		$ytvIDlen = 11;	// This is the length of YouTube's video IDs
		
		// The ID string starts after "v=", which is usually right after 
		// "youtube.com/watch?" in the URL
		$idStarts = strpos($ytURL, "?v=");
		
		// In case the "v=" is NOT right after the "?" (not likely, but I like to keep my 
		// bases covered), it will be after an "&":
		if($idStarts === FALSE)
			$idStarts = strpos($ytURL, "&v=");
		// If still FALSE, URL doesn't have a vid ID
		if($idStarts === FALSE)
			die("YouTube video ID not found. Please double-check your URL.");
		
		// Offset the start location to match the beginning of the ID string
		$idStarts +=3;
		
		// Get the ID string and return it
		$ytvID = substr($ytURL, $idStarts, $ytcIDlen);
		
		return $ytvID;
		
	}
?>

thankx alot!! after i changed the last parameter $ytvIDlen it worked Greatly))
One last Question,how is it possible to display the thumbanail of the Video???

This article has been dead for over six months. Start a new discussion instead.