I am trying to obtain embeded code through extracting variables from Youtube video URLs. So far I have the old way of embedding working but not the Iframe way. The Iframe works fine if the url only has the 11 characters after "watch?v=" but the issue comes when the url contains "&feature=g" the 11 characters. Is there a solution to strip off the "&feature=g" or maybe a better way? Second and less important, every time i click autoplay i dont obtain an autplay result with video? Here is my EXAMPLE
PHP for obtaining embeded code
<?php
$vari ='';
if($_POST)
{
$vari = $_POST['yurl'];
$hth = 300; //$_POST['yheight'];
$wdth = 500; //$_POST['ywidth'];
$is_auto = 0;
$step1 =explode ('v=', $vari);
$step2 =explode ('&',$step1[1]);
if(isset($_POST['yautop'] ))
{
if($_POST['yautop'] == 1)
$is_auto = 1;
}
$auto1 = '?autoplay='.$is_auto;
$auto2 = '&autoplay='.$is_auto;
//Iframe code
echo ('<iframe src="http://www.youtube.com/embed/'.$step2[0].'" frameborder="0" width="'.$wdth.'" height="'.$hth.'"></iframe>');
//Old way to embed code
echo ('<embed width="'.$wdth.'" height="'.$hth.'" type="application/x-shockwave-flash" src="http://www.youtube.com/v/'.$step2[0].'" wmode="transparent" embed="" /></embed>');
}
?>
html
<html>
<form method="post" action="">
URL:
<input type="text" value="<?php $vari ?>" name="yurl"> <!--$vari-->
<br>
<br>
Autoplay:
<input type="checkbox" value="<?php $auto1; $auto2; ?>" name="yautop"> <!--$auto1 $auto2-->
<br>
<input type="submit" value="Generate Embed Code" name="ysubmit">
<br>
</form>
</html>