Jump to content

Run Youtube Videos In Topic?


Recommended Posts

Thank you for your clarification...I am assuming that you want almost a bbcode to post a video..Well lets take a look at a youtube embed code for this video:

:
<object width="480" height="295"><param name="movie" value="http://www.youtube.com/v/uoP-adqg7P4&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/uoP-adqg7P4&hl=en&fs=1" typehttp://w3schools.invisionzone.com/index.php?showtopic=23524&st=0&gopid=130028="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="295"></embed></object>

We see this referenced twice:

That would be the direct location of the SWF and the video player, so to manipulate it we have to understand the URL.../v/uoP-adqg7P4&hl=en&fs=1Okay the green part is the name of the video, the red part is stuff you do not need to worry about, so the video at
can be referenced at
which means the video's ID is uoP-adqg7P4.So all you need to do is ask for the user's video ID and rebuild the embed code with that video ID number...
<?php$vid = "uoP-adqg7P4";echo '<object width="480" height="295"><param name="movie" value="http://www.youtube.com/v/$vid&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/$vid&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="295"></embed></object>';?>

Link to post
Share on other sites
One problem with your code zachary, variable interpolation requires that the string starts with a " not a '. So change both ' that form the string, and change to " and escaping all of the other " backslashes like \".
It is not a problem since that data the variable will be containing isn't a quote, I did not have the time to add the slashes so I just changed it to a single quote, insecure & sloppy, Yes, but I was just giving an example.
Link to post
Share on other sites
I did not have the time to add the slashes
Huh? Cause it takes a while? But writing a bad example is better?It is incorrect. You can't do variable replacement in single-quoted strings, only double-quoted. Run your example and you'll see it prints out the string '$vid', not the value of that variable.
<?php$vid = "uoP-adqg7P4";echo "<object width=\"480\" height=\"295\"><param name=\"movie\" value=\"http://www.youtube.com/v/{$vid}&hl=en&fs=1\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/v/{$vid}&hl=en&fs=1\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"480\" height=\"295\"></embed></object>";?>

or:

<?php$vid = "uoP-adqg7P4";echo '<object width="480" height="295"><param name="movie" value="http://www.youtube.com/v/' . $vid . '&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' . $vid . '&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="295"></embed></object>';?>

Link to post
Share on other sites

I'm sorry but this is free help, I gave him the principle on how to do it, and he hasn't comeback with that error which means he got the principle from my code, and implemented it in a working fashion :) Also there is no reason to get angry at me since, I don't get that error on PHP 4... So your answer is really only applicable to php 4+..

Link to post
Share on other sites

First, I'm not angry with you. Second, string handling did not change between PHP 4 and PHP 5. Run this on PHP 4 and see what happens:

$test = 123;echo 'the variable is $test';

Third, PHP 4 is 8 or 9 years old now, the majority of people don't use it anymore. PHP 5 has several performance and security improvements that are missing in PHP 4, not to mention the extra extensions and functions (e.g. file_get_contents). And PHP 6 is close to being ready. It's probably time to move on from PHP 4.When you were starting out and asking questions, I didn't give you half answers just because I'm not charging you for my time. I gave your questions the same consideration I give other people.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...